上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 51 下一页
摘要: 2011-12-23 08:57:38地址:http://acm.hdu.edu.cn/showproblem.php?pid=1079题意:给个日期(从1900-1-1开始的)。两个人轮流操作,每次可以把日期变成后一天,或者是下月的当天(若不存在,则不可变)。谁走到2001-11-4就赢。问先手有无必胜策略。mark:记忆化爆搜。代码:# include <stdio.h># include <string.h>int dp[2200][15][35] ;int month[2][13] = { {0, 31, 28, 31, 30, 31, 30, 31, 31, 阅读全文
posted @ 2012-01-06 23:31 Seraph2012 阅读(322) 评论(2) 推荐(0) 编辑
摘要: 2011-12-23 09:08:47地址:http://acm.hdu.edu.cn/showproblem.php?pid=1284题意:面额为1、2、3的硬币组成n有多少种。mark:标准母函数,不过用dp搞了。dp[i][j]表示前i种硬币组成面额j的情况数,有dp[i][j] = dp[i-1][j] + dp[i][j-i]。代码:# include <stdio.h>int dp[4][40000] ;int main (){ int i, j, n ; dp[0][0] = 1 ; for (i = 1 ; i <= 3 ; i++) for (... 阅读全文
posted @ 2012-01-06 23:31 Seraph2012 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 2011-12-23 08:04:50地址:http://acm.hdu.edu.cn/showproblem.php?pid=2117题意:问1/n的小数点后第m位是多少。高精度除法。代码:# include <stdio.h>int gao(int n, int m){ int i, dividend=1, quotient, remainder ; for (i = 0 ; i <= m ; i++) { quotient = dividend/n ; remainder = dividend % n ; dividend = ... 阅读全文
posted @ 2012-01-06 23:30 Seraph2012 阅读(195) 评论(0) 推荐(0) 编辑
摘要: 2011-12-23 08:29:57地址:http://acm.hdu.edu.cn/showproblem.php?pid=2189题意:中文。把n拆成素数和有几种拆法。mark:本是标准母函数,不过用dp也可以YY一下。dp[i][j]表示用最大不超过i的素数组成j有多少种方法。如果i不是素数,直接和i-1的情况相同,如果i是素数,有dp[i][j] = dp[i][j-i] + dp[i-1][j]代码:# include <stdio.h># include <string.h>int dp[200][200] ;int n ;int IsPrime[200] 阅读全文
posted @ 2012-01-06 23:30 Seraph2012 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 2011-12-23 07:49:22地址:http://acm.hdu.edu.cn/showproblem.php?pid=1042题意:算n!。最高10000。1w的时候n!有不超过4w位(Log10(10000^10000) = 40000)。代码:# include <stdio.h># define MOD 10000int num[40000] ;void mul(int n){ int i, cc = 0 ; for (i = 1 ; i <= num[0] ; i++) { num[i] = num[i]*n + cc ; cc ... 阅读全文
posted @ 2012-01-06 23:29 Seraph2012 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 2011-12-23 07:55:30地址:http://acm.hdu.edu.cn/showproblem.php?pid=1390题意:中文。水。代码:# include <stdio.h>int main (){ int T, i, n, flag ; scanf ("%d", &T) ; while (T--) { scanf ("%d", &n) ; flag = 0 ; for (i = 0 ; (1<<i) <= n ; i++) { if (n&(1<<i)) ... 阅读全文
posted @ 2012-01-06 23:29 Seraph2012 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 2011-12-23 06:35:53地址:http://acm.hdu.edu.cn/showproblem.php?pid=1849题意:中文。mark:NIM博弈,SG函数,还是缺乏感性认识,wa了2次。代码:# include <stdio.h>int main (){ int n, sg, num ; while (~scanf ("%d", &n) && n) { sg = 0 ; while (n--) { scanf ("%d", &num) ; sg ^= num ; ... 阅读全文
posted @ 2012-01-06 23:28 Seraph2012 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 2011-12-23 07:30:49地址:http://acm.hdu.edu.cn/showproblem.php?pid=1517题意:S和O玩游戏,S先动。一开始P=1,每次让它乘以2或9,超过n的获胜。问最后谁赢。mark:虽然是博弈。。。但是貌似很麻烦,直接记忆化爆之。。。代码:# include <stdio.h># include <string.h>int dp[40][40] ;long long n ;long long pow(int a, int b){ long long ans = 1 ; int i ; for (i = 0 ; i &l 阅读全文
posted @ 2012-01-06 23:28 Seraph2012 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 2011-12-23 05:06:19地址:http://acm.hdu.edu.cn/showproblem.php?pid=1850题意:中文。mark:上一题(1847)是博弈,搜过了,这题还是博弈,迫不得已看了一下NIM博弈。假设数量是a1,a2,a3...an。令k = a1^a2^a3..^an。其中"^"表示异或。令ai' = ai ^ k。若ai' < ai,则表示ai这堆取成ai'可以让对方必败,即为先手的一种可行走法。代码:# include <stdio.h>int a[110] ;int main (){ i 阅读全文
posted @ 2012-01-06 23:27 Seraph2012 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 2011-12-23 06:07:41地址:http://acm.hdu.edu.cn/showproblem.php?pid=1846题意:中文。mark:考虑n%(m+1)是否为0。代码:# include <stdio.h>int main (){ int T, n, m ; scanf ("%d", &T) ; while (T--) { scanf ("%d%d", &n, &m) ; puts (n%(m+1) ? "first" : "second") ; } re 阅读全文
posted @ 2012-01-06 23:27 Seraph2012 阅读(95) 评论(0) 推荐(0) 编辑
上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 51 下一页