2014年2月28日

codeforces #232 div2 解题报告

摘要: A:简单题;我们可以把点换成段处理,然后枚举段看是否被霸占了;#include#include#include#includeusingnamespacestd;intb[1000];intmain(){intn;cin>>n;intl,r;cin>>l>>r;for(inti=l;i>l>>r;for(inti=l;i=a) cout#include#include#includeusingnamespacestd;mapv;constintmod=1000000007;intc[18000][1000];intn,a[1000],cnt 阅读全文

posted @ 2014-02-28 23:47 forgot93 阅读(430) 评论(0) 推荐(0) 编辑

2014年2月25日

Codeforces Round #231 (Div2) 迟到的解题报告

摘要: 题目A: 给一个火柴等式,可以从左边移动一根到右边,也可以从右边移到左边,但是不能移动“+”,”=“的火柴,而且加法里面的数都要大于0(很重要的条件),基本上注意到这点的都过了,没注意的都被HACK了。#include#include#include#include#include#includeusingnamespacestd;intn;intmain(){strings;cin>>s;inta,b;a=b=0;inti=0;for(;i#include#include#include#include#includeusingnamespacestd;inta[2000000] 阅读全文

posted @ 2014-02-25 17:03 forgot93 阅读(211) 评论(0) 推荐(0) 编辑

2014年2月20日

贴代码—CF230 DIV1 B

摘要: 题目在此:http://codeforces.com/contest/392/problem/B 一直理解错了一句话,以为是用最小的move求最小的花费, 读错题目的有木有!!! 不懂汉诺塔的原理有木有!!!! 记忆化DP即可。。。。。。 方程: long long ans1=dfs(n-1,a,b)+cost[a][c]+dfs(n-1,b,c); long long ans2=dfs(n-1,a,c)+cost[a][b]+dfs(n-1,c,a)+cost[b][c]+dfs(n-1,a,c); dp[n][a][c]=min(ans1,ans2);完整代码:#in... 阅读全文

posted @ 2014-02-20 22:16 forgot93 阅读(235) 评论(0) 推荐(0) 编辑

2014年2月18日

C++ 运算符优先级

摘要: http://en.cppreference.com/w/cpp/language/operator_precedence以后没事来查查了,很实用 阅读全文

posted @ 2014-02-18 16:04 forgot93 阅读(134) 评论(0) 推荐(0) 编辑

2013年12月29日

HDOJ 1069 DP

摘要: 开启DP之路题目:http://acm.hdu.edu.cn/showproblem.php?pid=1069描述一下:就是给定N(Na[i].x&&a[j].y>a[i].y) ans=max(ans,a[j].h+a[i].h); a[i].h=ans;#include#include#includeusingnamespacestd;structnode{intx,y,h;}a[1000];intcmp(nodex,nodey){if(x.x==y.x)returnx.y>y.y;returnx.x>y.x;}intmain(){intn;intt=0; 阅读全文

posted @ 2013-12-29 02:22 forgot93 阅读(286) 评论(0) 推荐(0) 编辑

2013年12月27日

HDU1506

摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1506题意很简单。然后这个做法:左右扫+迭代的过程很巧妙向左扫:for(inti=1;i=a[i])//重点 l[i]=l[l[i]-1]; 向右扫:for(inti=n;i>=1;i--)while(a[r[i]+1]>=a[i]) r[i]=r[r[i]+1]; 提供几个样例: 4 2 2 5 5 结果106 2 5 2 5 5 2 结果12加强版题目:在矩阵中求最大矩形面积HDOJ 1505再套一成循环:for(inti=1;i=p[i])l[i]=l[l[i]-1];for(in.. 阅读全文

posted @ 2013-12-27 22:16 forgot93 阅读(224) 评论(0) 推荐(0) 编辑

2013年12月24日

一道二分题

摘要: 题目:Problem DescriptionGashuai is a brave man live in a grand castle peacefully.However, there are many monsters want to invade the castle one day. Gashuai, the hero of the castle, want to defend the castle against monsters. The monsters comes one by one and each monster cost Gashuai a[i] HP to kill 阅读全文

posted @ 2013-12-24 17:11 forgot93 阅读(197) 评论(0) 推荐(0) 编辑

2013年12月16日

HDU1115

摘要: 写的很好的求重心的文章 转载下下 URAL:http://www.cnblogs.com/try86/archive/2012/04/21/2462458.html主要是求HDU1115 阅读全文

posted @ 2013-12-16 21:28 forgot93 阅读(60) 评论(0) 推荐(0) 编辑

判断线段是否相交

摘要: 1 double mul(node a,node b,node c)//c叉积运算 2 { 3 return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x); 4 } 5 int judge(node a,node b,node c,node d)//判断线段两个点是否在一条线段的两端,要对两条线段都判断 6 { 7 double p1=mul(a,c,b); 8 double p2=mul(a,d,b); 9 if (p1*p2<=0&&!(p1==0&&p2==0)) return 1;//这里有题目可能两条线段重合,所 阅读全文

posted @ 2013-12-16 16:30 forgot93 阅读(145) 评论(0) 推荐(0) 编辑

2013年12月15日

atan atan2的区别!

摘要: atan与atan2的使用=范围不一样!今天调一一下午的BUG!终于发现了是ATAN的错!atan()函数: atan(y/x);带一个参数!注意X不能为0,否则…………,还有求出的角度为-pi/2----pi/2,不包括-Pi/2,pi/2,而atan2(y,x);y在前,x在后,而且x,y可以分别为0,但不能同时为0,atan2函数值为(-pi,pi),开区间;一般来说ACM里面用的广的是atan2; 阅读全文

posted @ 2013-12-15 16:05 forgot93 阅读(344) 评论(0) 推荐(0) 编辑

2013年12月6日

感想!12 06

该文被密码保护。 阅读全文

posted @ 2013-12-06 23:59 forgot93 阅读(0) 评论(0) 推荐(0) 编辑

2013年11月30日

HDOJ1050

摘要: Moving TablesTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 16129Accepted Submission(s): 5542Problem DescriptionThe famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure.The floor has 阅读全文

posted @ 2013-11-30 22:49 forgot93 阅读(185) 评论(0) 推荐(0) 编辑

Codeforces Round #216 (Div. 2)解题报告

摘要: 又范低级错误!只做了两题!一道还被HACK了,囧!A:看了很久!应该是到语文题:代码:#include#includeusingnamespacestd;intmain(){intn,m,k;cin>>n>>m>>k;inta[10000];intm1=0,m2=0;for(inti=1;i>a[i];if(a[i]==1)m1++;elsem2++;}intans=0;if(m>=m1)ans=m1+m2-m-k;else{ans=m1-m;if(kA[K];先每个都初始化为L;然后从A[1]-->A[K]递加,这里最好用除法,加法的太慢 阅读全文

posted @ 2013-11-30 09:49 forgot93 阅读(388) 评论(7) 推荐(0) 编辑

2013年11月29日

容斥定理!

摘要: 练习题目:HDU 4135;http://acm.hdu.edu.cn/showproblem.php?pid=4135程序:#include#include#include#includeusingnamespacestd;vectorvt;//第一次用栈!很好用longlongn,a,b,ret;longlongque[10000];voidfx(){vt.clear();ret=n;for(inti=2;i*i1)vt.push_back(ret);}longlongAns(longlongn,longlongx)//核心:其实我以为要用麻烦的DFS,队列解决!而且很好弄{intnum= 阅读全文

posted @ 2013-11-29 22:30 forgot93 阅读(152) 评论(0) 推荐(0) 编辑

2013年11月27日

CF214DIV 2

摘要: 不得不吐槽一下!会的第一,第二题得过了PROTEST!结果各种BUG!第一题:我的英语太渣了!!!很水的一道题!第二道:更水!结果悲剧!#includeint a[200000];int main(){ int n,k; scanf("%d%d",&n,&k); for (int i=1;i<=n;i++) scanf("%d",&a[i]); int max1=109999999,p;//int max的初始值弄错了,结果挂在最后一组!无语!! for (int i=1;i<=k;i++) { int sum=a[i 阅读全文

posted @ 2013-11-27 00:54 forgot93 阅读(120) 评论(0) 推荐(0) 编辑

2013年11月24日

HDOJ3398

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3398很好的题目,考查数学思想!基本上是快速幕+ N!的快速质因数分解,看了他人的解题报告:我写的代码: 1 #include 2 #include 3 #include 4 const int max1=2000001; 5 int pri[max1]; 6 int b[max1]; 7 int ci[max1]; 8 int t=0; 9 void prime()10 {11 for (int i=4;i=pri[i];i++)59 while (kk%pri[... 阅读全文

posted @ 2013-11-24 09:32 forgot93 阅读(124) 评论(0) 推荐(0) 编辑

2013年11月23日

HDU-2136(素数问题)

摘要: Largest prime factorTime Limit: 5000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4916Accepted Submission(s): 1728Problem DescriptionEverybody knows any number can be combined by the prime number.Now, your task is telling me what position of the largest prime fa 阅读全文

posted @ 2013-11-23 22:12 forgot93 阅读(116) 评论(0) 推荐(0) 编辑

2013年11月19日

HDOJ1391

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1391其实就是找规律的题目,但是我一眼没看到规律!于是按照自己的方法写!代码: 1 #include 2 #include 3 #include 4 using namespace std; 5 6 struct node{ 7 int x1,y1; 8 int num; 9 }a[20000];10 int cmp(node x,node y)11 {12 if (x.x1==y.x1) return x.y1<y.y1;13 return x.x1<y.x1;1... 阅读全文

posted @ 2013-11-19 08:11 forgot93 阅读(97) 评论(0) 推荐(0) 编辑

2013年11月16日

CF212DIV2

摘要: A题: 题目呢连接:http://codeforces.com/contest/362/problem/A。刚开始想用DFS搜索,但是忘记了:可以move through"#"这个条件!就是说可以走到"#"(很关键),但不能在这里相聚!直接委掉了!先贴下DFS的代码写的很垃圾! 1 #include 2 #include 3 #include 4 5 int x[4]={-2,2,-2,2}; 6 int y[4]={-2,-2,2,2}; 7 8 int t; 9 char s[10][10];10 int v[10][10],b[10][10];11 阅读全文

posted @ 2013-11-16 00:56 forgot93 阅读(254) 评论(0) 推荐(0) 编辑

导航