摘要:
2011-12-20 06:54:39地址:http://acm.hdu.edu.cn/showproblem.php?pid=2523题意:中文。mark:运用到桶排序。代码:# include <stdio.h>int x[2010], flag[2010] ;int cnt ;int abs(int n){return n<0?-n:n;}int main (){ int T, n, k, i, j ; scanf ("%d", &T) ; while (T--) { scanf ("%d%d", &n, & 阅读全文
posted @ 2012-01-06 22:52
Seraph2012
阅读(188)
评论(0)
推荐(0)
摘要:
2011-12-20 06:44:37地址:http://acm.hdu.edu.cn/showproblem.php?pid=2521题意:中文。mark:反素数直接for for暴力求,约莫计算不到10w次。查询可用ST算法,但这题没必要,直接扫就好了。代码:# include <stdio.h>int factor[5010] ;void init(){ int i, j ; for (i = 2 ; i <= 5000 ; i++) { for (j = i ; j <= 5000 ; j+= i) factor[j] ++ ; ... 阅读全文
posted @ 2012-01-06 22:51
Seraph2012
阅读(171)
评论(0)
推荐(0)
摘要:
2011-12-20 06:30:12地址:http://acm.hdu.edu.cn/showproblem.php?pid=2519题意:中文。其实就是算组合数。mark:即使是long long,算阶乘也只能算到20!,因此用杨辉三角比较简单。代码:# include <stdio.h>int c[31][31] ;void init(){ int i, j ; c[0][0] = 1 ; for (i = 1 ; i <= 30 ; i++) { c[i][0] = 1 ; for (j = 1 ; j <= i ; j++) ... 阅读全文
posted @ 2012-01-06 22:50
Seraph2012
阅读(167)
评论(0)
推荐(0)
摘要:
2011-12-20 06:25:07地址:http://acm.hdu.edu.cn/showproblem.php?pid=1701题意:求一个最小的n,满足n*p%和n%q%中间夹着一个整数。mark:题意真是太诡异了。看了discuss才知道啥意思。最大不会超过10000, 直接搜过。代码。# include <stdio.h>int gcd(int a, int b){return a%b==0?b:gcd(b,a%b) ;}int main (){ int T, i, p, q ; double pp, qq ; scanf ("%d", & 阅读全文
posted @ 2012-01-06 22:49
Seraph2012
阅读(182)
评论(0)
推荐(0)
摘要:
2011-12-20 06:11:14地址:http://acm.hdu.edu.cn/showproblem.php?pid=2537题意:中文,模拟。代码:# include <stdio.h>int gao(int n){ char ch ; int r = 7, y = 7 ; while (n--) { scanf ("%c", &ch) ; if (ch == 'R') r-- ; if (ch == 'Y') y-- ; if (ch == 'B') return r==0 ; if (... 阅读全文
posted @ 2012-01-06 22:48
Seraph2012
阅读(190)
评论(0)
推荐(0)
摘要:
2011-12-20 05:55:00地址:http://acm.hdu.edu.cn/showproblem.php?pid=1868题意:问n可以表示成连续数字和有多少种。mark:和2058如出一辙。TLE了2次,忘记改成long long,算sqrt的时候有个8倍会溢出。代码:# include <stdio.h># include <math.h>typedef long long ll ;ll calc (ll b){ int ans = 0 ; ll n, p ; for (n = ((ll)sqrt(8*b+1)-1) / 2 ; n > 1 ; 阅读全文
posted @ 2012-01-06 22:47
Seraph2012
阅读(151)
评论(0)
推荐(0)
摘要:
2011-12-20 05:34:39地址:http://acm.hdu.edu.cn/showproblem.php?pid=2106题意:n个不同进制的数求和。代码:# include <stdio.h>int base(int a, int b){ if (a == 0) return 0 ; return b * base(a/10, b) + a%10 ;}int main (){ int n, sum, a, b ; while (~scanf ("%d", &n)) { sum = 0 ; while (n--) ... 阅读全文
posted @ 2012-01-06 22:46
Seraph2012
阅读(184)
评论(0)
推荐(0)
摘要:
2011-12-20 05:26:53地址:http://acm.hdu.edu.cn/showproblem.php?pid=1405题意:分解素因子。mark:PE2次。每行最后有一个空格。太无聊了- -。代码:# include <stdio.h>void output(int n){ int i, cnt ; for (i = 2 ; n != 1 ; i++) { if (n%i==0) { cnt = 0 ; while (n%i==0){cnt++; n/=i;} pr... 阅读全文
posted @ 2012-01-06 22:45
Seraph2012
阅读(212)
评论(2)
推荐(1)
摘要:
2011-12-20 05:17:41地址:http://acm.hdu.edu.cn/showproblem.php?pid=1279题意:中文。没啥好说的。代码:# include <stdio.h>int output (int n){ int flag = 0 ; while (n!=1) { if (n&1) { if (flag == 0) flag = 1 ; else printf (" ") ; printf ("%d", n) ; n = 3... 阅读全文
posted @ 2012-01-06 22:44
Seraph2012
阅读(122)
评论(0)
推荐(0)
摘要:
2011-12-20 05:12:48地址:http://acm.hdu.edu.cn/showproblem.php?pid=2352题意:罗马数字转阿拉伯数字。mark:居然wa了一次。把%d写成了%s,太2了。看似麻烦,其实简单。降序为正,升序为负,遍历即可。代码:# include <stdio.h>char str[110] ;int num[110] ;int n ;int calc(){ int i, j, ans = 0 ; for (i = 0 ; i < n ; i++) { ans += num[i] ; for (j = i... 阅读全文
posted @ 2012-01-06 22:43
Seraph2012
阅读(154)
评论(0)
推荐(0)

浙公网安备 33010602011771号