上一页 1 ··· 27 28 29 30 31 32 33 34 35 ··· 51 下一页
摘要: 2011-12-18 05:46:17地址:http://acm.hdu.edu.cn/showproblem.php?pid=1058题意:找质因数只有2 3 5 7的第i个数。mark:本来是dp,但是为了寻找一种新的比较好做的解法,可以这样做:假设dp[i]表示第i个满足条件的数字,则dp[i]一定由前i-1个数字乘以2、3、5、7中的一个数得到。枚举前i-1个数每个乘以2、3、5、7,得到的不小于dp[i-1]的最小值为dp[i]。递推。复杂度应该是5000*5000*4,不过加优化勉强能过。代码:# include <stdio.h>typedef long long l 阅读全文
posted @ 2012-01-06 22:22 Seraph2012 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 2011-12-18 03:16:34地址:http://acm.hdu.edu.cn/showproblem.php?pid=1005题意:求公式的第n项。f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.mark:矩阵乘法,快速幂。代码:# include <stdio.h># define REP(i,a) for(i = 0 ;i < a ; i++)void mul(int a[2][2], int b[2][2]){ int i, j, c[2][2] ; c[0][0] = (a[0][ 阅读全文
posted @ 2012-01-06 22:20 Seraph2012 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 2011-12-18 00:49:29地址:http://acm.hdu.edu.cn/showproblem.php?pid=2148题意:中文。。。代码:# include <stdio.h>int a[1010] ;int main (){ int T, n, pos, i, ans ; scanf("%d", &T) ; while (T--) { scanf ("%d%d", &n, &pos) ; for (i = 1; i <= n ; i++) scanf ("%d", &am 阅读全文
posted @ 2012-01-06 22:18 Seraph2012 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 2011-12-17 08:06:00不在状态,写到天亮才写完200题。卡1052卡了很久。感觉有的题已经不能算水题了。刷题不能重量不重质,之后会放慢速度,充分想清楚每一题的得失才可以。 阅读全文
posted @ 2012-01-06 22:16 Seraph2012 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 2011-12-17 08:03:16地址:http://acm.hdu.edu.cn/showproblem.php?pid=2143题意:有3个数字abc,五种操作(+-*/%),如果有一个数字能被另外两个数字用那5种操作之一一次计算出来,则输出oh,lucky!,否则输出what a pity!。此题中除法不是整除。mark:因为减法和除法包含在加法和乘法内,所以不需要单独判断。取mod注意模数不为0。另外加法和乘法会超int界,用long long。代码:# include <stdio.h>typedef long long ll ;ll test(ll a, ll b, 阅读全文
posted @ 2012-01-06 22:15 Seraph2012 阅读(248) 评论(0) 推荐(1) 编辑
摘要: 2011-12-17 07:47:56地址:http://acm.hdu.edu.cn/showproblem.php?pid=2074题意:中文。模拟。代码:# include <stdio.h># include <string.h>char out[110][110] ;void gao(int n, char a[2]){ memset (out, 0, sizeof(out)) ; if (n == 1){ putchar (a[0]) ; puts ("") ; return ; } int s = 0, t... 阅读全文
posted @ 2012-01-06 22:14 Seraph2012 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 2011-12-17 07:35:12地址:http://acm.hdu.edu.cn/showproblem.php?pid=1283题意:中文。模拟题。代码:# include <stdio.h>char str[1010] ;int r1, r2, r3 ;int m1, m2 ;void handle(){ int i ; r1 = r2 = r3 = 0 ; for (i = 0 ; str[i] ; i++) { switch (str[i]) { case 'A': r1 = m1 ; break ; ... 阅读全文
posted @ 2012-01-06 22:13 Seraph2012 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 2011-12-17 07:29:24地址:http://acm.hdu.edu.cn/showproblem.php?pid=1257题意:中文。最少拦截系统。mark:经典dp。最少拦截系统数=最长非降子序列(LIS)数。O(n^2)水过。代码:# include <stdio.h>int a[1010] ;int dp[1010] ;int n ;int max(int a, int b){return a>b?a:b;}int lis(){ int i, j, ans = 0 ; dp[0] = 1 ; for (i = 1 ;i < n ; i++) { .. 阅读全文
posted @ 2012-01-06 22:12 Seraph2012 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 2011-12-17 07:19:48地址:http://acm.hdu.edu.cn/showproblem.php?pid=1159题意:求两个字符串的最长公共字串(LCS)。mark:经典dp。dp[i][j]表示a的前i个字符和j的前i个字符的LCS长度。有dp[i][j] = max(dp[i-1][j-1]+(a[i]==b[j]), dp[i-1][j], dp[i][j-1])。代码:# include <stdio.h># include <string.h>int dp[1010][1010] ;char s1[1010], s2[1010] ;in 阅读全文
posted @ 2012-01-06 22:11 Seraph2012 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 2011-12-17 07:00:30地址:http://acm.hdu.edu.cn/showproblem.php?pid=2072题意:中文。统计“不同”单词。字符串处理。代码:# include <stdio.h># include <string.h>char str[1010] ;char words[1010][50] ;int n ;void getword(char str[]){ int flag = 0 ; int len = strlen(str) ; int cnt = 0 ; char word[50] ; int i ; str... 阅读全文
posted @ 2012-01-06 22:10 Seraph2012 阅读(141) 评论(0) 推荐(0) 编辑
上一页 1 ··· 27 28 29 30 31 32 33 34 35 ··· 51 下一页