摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1418题意:中文。mark:1wa。虽然n、m都是整形范围,但是加起来可能会超过,因此要用long long。不存在m < 2的情况。代码:# include <stdio.h>int main (){ long long n, m ; while (~scanf ("%I64d%I64d", &n, &m) && (n||m)) printf ("%I64d\n", n+m-2) ; return 0 ;} 阅读全文
posted @ 2012-01-13 23:31 Seraph2012 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1562题意:求最小的[1000,9999]区间内的数x满足x%a==0 && (x+1)%b==0 && (x+2)%c==0。mark:应该是用剩余定理的,不过数据那么小,直接爆了。代码:# include <stdio.h>int main (){ int T, a, b, c, i ; scanf ("%d", &T) ; while (T--) { scanf ("%d%d%d", &a, &am 阅读全文
posted @ 2012-01-13 23:21 Seraph2012 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1999题意:中文。mark:打表到100w。。。(上限是试出来的。。。)代码:# include <stdio.h>int sum[1000010] ;int dp[1010] ;void init(){ int i, j ; for (i = 1 ; i <= 500000 ; i++) for (j = 2*i ; j <= 1000000 ; j+= i) sum[j] += i ; for (i = 2 ; i <= 1000000 ; i+... 阅读全文
posted @ 2012-01-13 22:28 Seraph2012 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1088题意:写一个html代码显示的程序。。。mark:就是麻烦,没别的。各种PE。后来发现是只考虑了' '和'\n',忘记考虑'\t'。。。代码:# include <stdio.h>int main (){ int ch, cnt = 0, cc = 0 ; int flag = 0, end = 1 ; int i ; char buff[100] ;// freopen ("in.txt", "r" 阅读全文
posted @ 2012-01-13 21:20 Seraph2012 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2068题意:中文。mark:如果知道错排公式就很简单了。wa了一次。。。<=写成了<。。。PE一次。莫名其妙多加了个空格。sb了。代码:# include <stdio.h>long long c[30][30] = {1} ;long long cp[15] = {0, 0, 1} ;void init(){ int i, j ; for (i = 1 ; i <= 25 ; i++) { c[i][0] = 1 ; for (j = 1 ; j <= i... 阅读全文
posted @ 2012-01-13 07:08 Seraph2012 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1420题意:求a^b mod c。mark:快速幂无疑是最简单的写法。不过c只有100w,也可以用数论的方法做。此处用的是快速幂。代码:# include <stdio.h>int mod ;int qpow(long long a, long long b){ long long ans = 1, buff = a ; while (b) { if (b&1) ans = (ans*buff) % mod ; b >>= 1 ; buff =... 阅读全文
posted @ 2012-01-13 06:39 Seraph2012 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1072题意:I想(从2处)逃出迷宫(3处),0是墙,1是空地。身上有定时炸弹,在第6s爆炸(只能走5步)。4处是将定时炸弹重设的工具。问它最快能否逃出迷宫。mark:bfs。多添加一个数组标记上次到达当前位置时定时炸弹的剩余秒数。代码:# include <stdio.h># include <string.h>int n, m ;int graph[10][10] ;int step[10][10] ;int times[10][10] ;int sx, sy, ex, ey 阅读全文
posted @ 2012-01-13 06:34 Seraph2012 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1593题意:中文。mark:1wa。直接往开始的反方向按半径逃不可以。找一个同心圆,让V1的角速度略大V2。在那个圈上0086可以甩对方一个直径后再往岸边划。代码:# include <stdio.h># include <math.h># define Pi acos(-1)int main (){ int R, V1, V2 ; double t1, t2 ; while (~scanf ("%d%d%d", &R, &V1, &V 阅读全文
posted @ 2012-01-13 03:47 Seraph2012 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1231题意:中文。最大连续子川和。经典dp(不知道算不算dp)。代码:# include <stdio.h>int a[10010] ;int n, s, e, max_sum ;void find(){ int i, ss = s, ee = e, sum = max_sum ; for (i = 1 ; i < n ; i++) { if (sum < 0) ss = ee = sum = a[i] ; else { ... 阅读全文
posted @ 2012-01-13 02:46 Seraph2012 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1898题意:S和X比做题。他们的做题顺序是一样的,但并不是做一题交一题。S每A分钟交一次,X每B分钟交一次。问T分钟的时候是谁交的题多。mark:水。假设每分钟做1题,求出两人各自交了多少题后比较。。。代码:# include <stdio.h>int main (){ int T ; int a, b, t, aa, bb ; scanf ("%d", &T) ; while (T--) { scanf ("%d%d%d", &a, 阅读全文
posted @ 2012-01-13 01:50 Seraph2012 阅读(136) 评论(0) 推荐(0) 编辑