2012年4月11日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1248我乱搞的,标准做法01背包View Code #include <stdio.h>int test(int n){ if(n<150)return n; if(n>200&&n<300)return n-200; return n%50;}int main(){ int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); printf("%d\n 阅读全文
posted @ 2012-04-11 23:49 LegendaryAC 阅读(189) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1234和祖宗随机题号PK,由于这题first和end的初值赋反了,导致调试10分钟,最后以惨败收场。。。View Code #include <stdio.h>#include <string.h>#define INF 100000000int main(){ int t,n,i; int hb,mb,sb; int he,me,se; int first,end; char name[2][200],namec[200]; scanf("%d",&t); 阅读全文
posted @ 2012-04-11 22:29 LegendaryAC 阅读(355) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1181直接bfs,等号写成赋值了,wa两次。。。View Code #include <stdio.h>#include <string.h>char s[200];char graph[50][50];char vis[50];int q[50];int bfs(){ int front=0,rear=1; int ch,i; q[0]=1; while(front<rear) { ch=q[front++]; if(ch=='m'-'a')re 阅读全文
posted @ 2012-04-11 13:04 LegendaryAC 阅读(204) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2116判断两个k位带符号数的和有木有溢出。判断的时候注意不能用两个数的和判断,否则溢出的话会有bug。这里的方法是用最值减其中一个数,再和另一个数比较。View Code #include <stdio.h>int k;__int64 a,b;__int64 pow(int x,int y){ int i; __int64 s=1; for(i=0;i<y;i++) s*=x; return s;}#define MAX pow(2,63) int test(){ ... 阅读全文
posted @ 2012-04-11 12:33 LegendaryAC 阅读(244) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1283模拟View Code #include <stdio.h>int main() { int m1,m2,r1,r2,r3,i; char s[300]; while(~scanf("%d%d",&m1,&m2)) { scanf("%s",s); r1=r2=r3=0; for(i=0;s[i];i++) { switch(s[i]) { ... 阅读全文
posted @ 2012-04-11 00:23 LegendaryAC 阅读(213) 评论(0) 推荐(0) 编辑