2012年4月23日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1222题意:判断兔纸酱能否存活求最大公约数。分析:如狼能从0到1,则狼能到任意洞。要使狼能到1,则gcd(m,n)=1View Code #include <stdio.h>int gcd(int a,int b){ return a%b==0?b:gcd(b,a%b);}int main(){ int p,m,n; scanf("%d",&p); while(p--) { scanf("%d%d",&m,&n); if(gcd(m, 阅读全文
posted @ 2012-04-23 23:09 LegendaryAC 阅读(156) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4104第一遍看了眼数据,直接输出所有数的和加1,居然过了,不过我相信一切都是有原因的~View Code #include <stdio.h>int main(){ int n,s,a,i; while(~scanf("%d",&n)) { s=0; for(i=0;i<n;i++) { scanf("%d",&a); s+=a; } printf("%d\n",s+1); ... 阅读全文
posted @ 2012-04-23 22:48 LegendaryAC 阅读(200) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2719按要求处理字符串View Code #include <stdio.h>#include <string.h>int main(){ char s[1100]; char tab1[30]={' ','!','$','%','(',')','*'}; char tab2[10][20]={{"%20"},{"%21"},{&quo 阅读全文
posted @ 2012-04-23 22:35 LegendaryAC 阅读(194) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2734按规则计算就行,很简单、、、View Code #include <stdio.h>#include <string.h>int main(){ char s[1100]; char tab[30]={' ','A','B','C','D','E','F','G','H','I','J','K 阅读全文
posted @ 2012-04-23 22:24 LegendaryAC 阅读(197) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2700读懂了发现就是一个奇偶判断View Code #include <stdio.h>#include <string.h>int main(){ char s[1100]; int len,cnt,i; while(gets(s)) { cnt=0; if(s[0]=='#')break; len=strlen(s); for(i=0;i<len-1;i++) if(s[i]=='1')cnt++; ... 阅读全文
posted @ 2012-04-23 22:15 LegendaryAC 阅读(229) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2740题意:找到A,另A^N最接近B思路:逆向考虑,B^(1/n)上下取整,在各取N次幂,看哪个更接近Bps:注意上下取整View Code #include <stdio.h>#include <math.h>int main(){ int b,n; double temp; int p,q; while(scanf("%d%d",&b,&n),(b||n)) { temp=pow(b*1.0,1.0/n); p=floor(temp);//向下取 阅读全文
posted @ 2012-04-23 19:09 LegendaryAC 阅读(212) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1789贪心,按价值从大到小排序,然后尽可能的安排到截止时间View Code #include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct L{ int a,b;}L;L kk[1100];int cmp(const void*a,const void*b){ L*c=(L*)a; L*d=(L*)b; if(c->b==d->b) return c->a-d->a; r 阅读全文
posted @ 2012-04-23 14:34 LegendaryAC 阅读(124) 评论(0) 推荐(0) 编辑