上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 51 下一页
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2374题意:有n个碗,标号为1到n。每个碗内有一些小珠子。每次从一个碗里拿出一个珠子,此时要往所有编号小于它的碗内各放入一颗珠子。问要拿多少次才能把所有的珠子拿完。mark:直接模拟。没注意I64d,1wa。代码:# include <stdio.h>long long num[60] ;int main (){ int i, j, n ; long long rtn ; while (~scanf ("%d", &n),n) { rtn = 0 ; ... 阅读全文
posted @ 2012-02-16 08:48 Seraph2012 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1335题意:前面是一个7位a进制数,表示成后面的进制。如果超过7位则输出ERROR。直接模拟。代码:# include <stdio.h>char str[40] ;int chartonum(char ch){ if (ch >= '0' && ch <= '9') return ch-'0' ; return ch-'A'+10 ;}int gao(char str[], int b){ int 阅读全文
posted @ 2012-02-16 08:34 Seraph2012 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2370题意:一个数字可以表示成若干个fibonacci数的和。求表示成fib后“右移”1位的数字。mark:打表前30个fib数,然后用贪心法可算出任何数字的fib数表示形式,再累加。代码:# include <stdio.h># include <string.h>int fib[35] = {1,1} ;int tab[35] ;void init(){ int i ; for (i = 2 ; i <= 30 ; i++) fib[i] = fib[i-1]+fib[ 阅读全文
posted @ 2012-02-16 08:15 Seraph2012 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1342题意:从给定的集合里面选出6个数字按顺序输出。把所有的选择都输出。mark:直接dfs就好了。代码:# include <stdio.h>int k ;int num[20] ;int ans[6] ;void dfs(int idx, int n){ int i ; if (n == 6) { for(i = 0 ; i < n ; i++) if (i == 0) printf("%d",ans[i]) ; else ... 阅读全文
posted @ 2012-02-16 07:33 Seraph2012 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1361题意:对于一个合法的括号序列S,可以计算出P和W的值。P的第i个值表示第i个右括号前面有多少个左括号,W的第i个值表示第i个右括号会和前面第几个左括号匹配。现在给出P的值,求W的值。mark:因为数据很小,n的长度只有20,因此可以直接模拟,由P反求出S,然后由S直接求出P。代码:# include <stdio.h># include <string.h>char str[50] ;int p[50],w[50] ;int n ;void setstr(){ int nu 阅读全文
posted @ 2012-02-16 07:21 Seraph2012 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1715题意:算fibonacci数。mark:大数运算。第1000个fib数只有200多位,直接打表好了。代码:# include <stdio.h>int fib[1010][300] ;char str[300] ;void add(int a[], int b[], int c[]){ int *p, *q ; int i, cc = 0 ; if(a[0]<b[0])p=a, q=b ; else p = b, q=a ; for(i = 1 ; i<= q[0] ... 阅读全文
posted @ 2012-02-16 06:52 Seraph2012 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1370题意:有3个循环周期,周期天数分别为23、28、33。对于某一年,已知某年这3个周期的某一峰值分别是当年的第p、e、i天,问从第d天开始到最近一个满足3个周期都达到峰值的日期还有多少天。mark:据说是剩余定理。数据比较小,直接打表可过。比较蛋疼的是wa了很多次,因为算减法以后忘记取模了。。。代码:# include <stdio.h>int tab[40][40][40] ;int _0(int num){ if (num <= 0) return num + 21252 ; 阅读全文
posted @ 2012-02-16 06:42 Seraph2012 阅读(295) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1379题意:输入一堆字符串,按“逆序数值”排序。如果相同,按输入顺序。mark:50个字符串,每个长度是100,算逆序数是O(n^2),复杂度是500000,直接暴力可搞。数据比较水,排序直接用qsort不用考虑输入顺序。如果非要考虑也可以,加一个下标表示原来的序号,比较的时候多比较一下就OK了。代码:# include <stdio.h># include <stdlib.h>typedef struct STRING{ char str[110] ; int unsorted 阅读全文
posted @ 2012-02-16 04:12 Seraph2012 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1720题意:输入十六进制的a和b,输出十进制的a+b。代码:main(a,b){while(~scanf("%x%x",&a,&b))printf("%d\n",a+b);} 阅读全文
posted @ 2012-02-15 19:47 Seraph2012 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1393题意:一个钟面只有一根分针。对于一个数字d,把中面上的分针指向的时间s往后拨s的d倍。问给定d,重复这样的操作多少次能回拨到0。若不能则输出Impossible。mark:因为钟面只有60分钟,所以最多不会超过60次,直接暴力就可。代码:# include <stdio.h>int main (){ int i, s, d, cnt ; int tab[100] ; while (~scanf ("%d%d", &s, &d) && 阅读全文
posted @ 2012-02-15 19:09 Seraph2012 阅读(161) 评论(0) 推荐(0) 编辑
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 51 下一页