上一页 1 ··· 3 4 5 6 7 8 9 10 11 下一页
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1982这题真是够纠结的啊,开始是pe但找不出神马原因,后来看了别人的代码,发现我没考虑"-----######---##-#-#"这种情况,导致我的pe,应该输出10个空格才对。代码如下:#include"stdio.h"char word[28]={"0ABCDEFGHIJKLMNOPQRSTUVWXYZ"};char a[10005];void output(){ int i,s=0,state=0; for(i=0;a[i]!='\0& 阅读全文
posted @ 2012-05-14 03:36 朝圣の路 阅读(366) 评论(0) 推荐(0) 编辑
摘要: 这题要注意一下,字符串最后可能不是5的情况,这里容易遗漏!!!代码如下:#include"stdio.h"#include"string.h"#include"stdlib.h"int num[1000],count;char a[1005];int cmp(const void *a,const void *b){return *(int*)a-*(int*)b;}void convert(char *a){int i,s=0,state=0;for(i=0;a[i]!='\0';i++){if(a[i]!=' 阅读全文
posted @ 2012-05-13 16:31 朝圣の路 阅读(200) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1207这题不知道该说啥,看网上别人都说这题是水题,但是我觉得挺难的啊。思路是这样的,先把j个盘子挪到第四个杆上,然后再把剩下的用按照经典汉诺达的模型移到目标杆上。还有一点是要注意的。。汉诺塔问题中,把盘子移到任意一个杆子上所以得步数是一定的,虽然我还不知道是为什么!如果哪位大神知道的话麻烦您给我留言,谢谢啦!代码如下:#include"stdio.h"int main( ){__int64 num[65]={0,1,3},min;int i,j,n;num[64]=18433;for(i= 阅读全文
posted @ 2012-05-13 15:57 朝圣の路 阅读(615) 评论(2) 推荐(0) 编辑
摘要: 一旦遇到高次方连乘,一定要记得快速幂啊,太有用了!!! 阅读全文
posted @ 2012-05-12 21:10 朝圣の路 阅读(87) 评论(0) 推荐(0) 编辑
摘要: #include"stdio.h"#include"stdlib.h"struct ln{ int j,f; double p;}s[1005];int cmp(const void *a,const void *b){ return (*(ln*)a).p>(*(ln*)b).p?1:-1;}int main( ){ int m,n,i; double sum,sun; while(scanf("%d%d",&m,&n)&&(m!=-1||n!=-1)) { sum=sun=0; for(i=0 阅读全文
posted @ 2012-05-12 20:52 朝圣の路 阅读(372) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1248唉。。。这题,我不会完全背包问题,只能暴力了,还好数据比较弱,果断过了,但是用暴力方法过的感觉很不爽啊。代码如下:#include"stdio.h"int main( ){ int i,j,k,n,a,b,c,t; int max,x,y,z; scanf("%d",&t); while(t--) { scanf("%d",&n); max=0; a=n/150;b=n/200;c=n/350; for(i=0;i<=.. 阅读全文
posted @ 2012-05-10 14:59 朝圣の路 阅读(430) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1222个人觉得是一道挺经典的数论题,想了有一会儿,第一次wa了,一看才发现是求lcm时导致溢出,然后发现其实化简后根本用不到lcm只用到gcd就好。代码如下:#include"stdio.h"int gcd(int m,int n){ int a,b,c; a=m>n?m:n; b=m<n?m:n; c=a%b; while(c!=0) { a=b; b=c; c=a%b; } return b;}int main( )... 阅读全文
posted @ 2012-05-07 21:41 朝圣の路 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 恩。。。这题感觉挺经典的。。。开始wa了一次。。后来一看discuss,才知道原来i的三次方会溢出。然后改对了,代码如下:#include"stdio.h"__int64 a[100005],i;int main( ){ int n; for(i=1;i<=100000;i++) { if(i%3==0) a[i]=a[i-1]+i*i*i; else a[i]=a[i-1]+i; } while(scanf("%d",&n)&&n>=0) { printf("%I64d\... 阅读全文
posted @ 2012-05-07 19:18 朝圣の路 阅读(306) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1205这题如果想到了其实思路挺简单的,就是找最大的一组,然后往剩下的和里插空儿。#include"stdio.h"int main( ){ int n,i,t,a,max; __int64 sum; scanf("%d",&t); while(t--) { sum=max=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a); s... 阅读全文
posted @ 2012-05-06 21:17 朝圣の路 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 这道题当时看起来真是挺无语的。。。直到现在也没完全明白。科学家不缔造任何工具,而是揭示天然界中现成的隐躲着的真实,艺术家缔造真实的近似物。要猜到最年夜的数字m,也就是说,在1到m间的每一个数,你都能在n次内把它猜出来!http://hi.baidu.com/xiao%5Fyu%5Ffeng/blog/item/11ab800ed1a7a3236159f334.html幸福存在于一小我真正的工作中。所以说在最坏的情况下,在1到m间,你最多只要猜log2(m)+1(取整)次,所以易知==>m=2^n-1.即猜n次,你能猜到的最年夜的数为2^n-1.我们也可认为,在数1到2^n-1间,我们都可 阅读全文
posted @ 2012-05-06 19:27 朝圣の路 阅读(402) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 下一页