上一页 1 ··· 5 6 7 8 9 10 11 12 13 下一页
摘要: http://ac.jobdu.com/problem.php?id=1357高中数学课上好像做过这个题题目明确说了数据范围,所以用long long没有什么好的办法吧,先确定一个大致的范围,然后再在这个范围的开始向后找,找到第一个就停下来,还在草稿纸上画了下二次函数的图像~~ 1 #include <stdio.h> 2 #include <math.h> 3 long long calc(long long n) 4 { 5 long long s; 6 s=(long long)((sqrt(8*n)+1)*0.5); 7 for(;;s++){ 8 ... 阅读全文
posted @ 2011-12-18 21:20 linyvxiang 阅读(230) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1347第一次做时间这么严格的题目1.DFS超时2.并查集判断是否连通,prim求最小生成树,超时3.并查集判断是否连通,Kruskal求最小生成树,超时4.并查集+路径压缩判断是否连通,Kruskal求最小生成树,AC 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <queue> 5 #include <algorithm> 6 using namespace 阅读全文
posted @ 2011-12-11 21:50 linyvxiang 阅读(207) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1346 1 #include <stdio.h> 2 #include <algorithm> 3 using namespace std; 4 struct Cus{ 5 int id,s; 6 }; 7 8 struct Cus cu[1002]; 9 bool cmp(struct Cus a,struct Cus b)10 {11 if(a.s!=b.s)12 return a.s>b.s;13 return a.id<b.id;14 }15 int min(int a,... 阅读全文
posted @ 2011-12-11 10:31 linyvxiang 阅读(197) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2186 1 #include <stdio.h> 2 int calc(int n) 3 { 4 return n/10+(n%10==0?0:1); 5 } 6 int main() 7 { 8 int C; 9 scanf("%d",&C);10 {11 while(C--){12 int num1,num2,num3,n;13 scanf("%d",&n);14 num1=n/2;15... 阅读全文
posted @ 2011-12-09 23:12 linyvxiang 阅读(173) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1342开始时没太读懂题, “去掉一些括号" 其实换句话说,就是看看有多少括号匹配过。。。 比上一个容易些,不用管连续不连续,用上一题的代码就可以 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <stack> 5 using namespace std; 6 int N; 7 char str[1000002]; 8 bool flags[1000002] = { 阅读全文
posted @ 2011-12-09 11:11 linyvxiang 阅读(353) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1337在混乱中写完了最后一个循环,要时刻警惕越界。。 还有就是indent还是不会用,直接把代码缩进搞乱了 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <stack> 5 using namespace std; 6 int N; 7 char str[1000002]; 8 bool flags[1000002] = { false }; 9 10 stack < 阅读全文
posted @ 2011-12-09 10:58 linyvxiang 阅读(314) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problemset.php?page=4floyd算法,只要看新修建的路不是不可以加入其中已经存在的某条最短路中,使之更短就可以了 1 #include <stdio.h> 2 #include <stdlib.h> 3 int N,K; 4 int mat[302][302]; 5 int calc() 6 { 7 int i,j; 8 int sum=0; 9 for(i=1;i<=N;i++)10 for(j=i+1;j<=N;j++)11 sum+=mat[i][j];12 ... 阅读全文
posted @ 2011-12-09 09:59 linyvxiang 阅读(247) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2095好题,用STL MAP MLE了,Google了一下,我表示这个想法我自己是想不到的,好多大牛。。。主要原理 1个数异或他自己 =0 1个数异或0 = 他自己理解了上面这个就好办了,题目中说的其他数字都出现偶数次,只一个数出现一次 如果 将 0异或他们全部,结果将是只出现一次的那个数还有帮助理解的一点,异或满足交换律~~~ 1 #include <stdio.h> 2 int main() 3 { 4 int n,value,result=0; 5 while(scanf("%d& 阅读全文
posted @ 2011-12-02 10:27 linyvxiang 阅读(163) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1280STL很费内存,在九度上时就那样 1 #include <stdio.h> 2 #include <list> 3 #include <queue> 4 using namespace std; 5 int main() 6 { 7 int N,M; 8 int mat[3000]; 9 while(scanf("%d%d",&N,&M)!=EOF){10 int i,j;11 priority_queue<int> Q 阅读全文
posted @ 2011-11-29 20:59 linyvxiang 阅读(233) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2151 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 int cost_mat[102][102]; 5 int N,P,M,T; 6 int main() 7 { 8 while(scanf("%d%d%d%d",&N,&P,&M,&T)!=EOF){ 9 int i,j;10 memset(cost_mat,0,sizeof(cos 阅读全文
posted @ 2011-11-29 20:32 linyvxiang 阅读(199) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 下一页