上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 21 下一页
摘要: 题目链接题目就是让你找出一个数组中可以将这个数组中所有数整除的数,很明显,如果存在,这个数肯定是最小的一个。//cf 299A//2013-06-05-20.51#include #include #include using namespace std;const int maxn = 100005;int a[maxn];int main(){ int n; while (scanf("%d", &n) != EOF) { int m = 0x3f3f3f3f; for (int i = 0; i < n; i++) { ... 阅读全文
posted @ 2013-06-05 20:59 xindoo 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 题目链接就是给你两个日期,让你求两个日期之间差多少天。我先算出两个日期分别是公元多少天,然后相减得到结果。//cf 304B//2013-06-05-18.38#include #include int y, m, d;int a[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};int loop(int y){ if (y%4 == 0 && y%100 != 0 || y%400 == 0) return 1; return 0;}int count(){ int sum = 0; fo... 阅读全文
posted @ 2013-06-05 18:41 xindoo 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 题目链接给你一个n,计算出1 ≤ a ≤ b ≤ c ≤ n.使得由abc构成的三角形满足勾股定理,c为斜边。没有简单的方法,直接爆力,但是要注意,有些abc满足勾股定理的表达式,但不一定是三角形,所以要判断一下,根据三角形三边的性质,两边之和大于第三边,两边之差小于第三边。//cf304 A//2013-06-05-18.14#include #include int main(){ int n; while (scanf("%d", &n) != EOF) { int cnt = 0; for (int i = 1; i n) ... 阅读全文
posted @ 2013-06-05 18:18 xindoo 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 题目链接 给出一个非减序的数组a[n], 然后得到s=2^a1+.……+2^an, 要使s为2^v -1,需要在数组中添加几个数。 我的思路是这样的,由2^a+2^a = 2^(a+1)可知,如果有两个连续的数a,我们可以把他们合并为a+1放入集合中,使集合中没有重复的数,我可以用stl里的set。如果想要满足题目中的要求,集合中必须有最大那个数个元素,缺多少就可以计算出来了。代码://codeforces 305 C. Ivan and Powers of Two//2013-06-05-17.19#include #include #include #include using n... 阅读全文
posted @ 2013-06-05 17:26 xindoo 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 题目链接题目意思是在n*m的矩阵中,你可以对矩阵中的每个数加或者减d,求最少的操作次数,使得矩阵中所有的元素相同。虽然在condeforces中被分到了dp一类,但完全可以通过排序,暴力的方法解决。#include #include #include #include using namespace std;const int maxn = 10005;int a[maxn];int main(){ int n, m, d; while (scanf("%d %d %d", &n, &m, &d) != EOF) { int t = n*m; fo. 阅读全文
posted @ 2013-06-04 17:11 xindoo 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 题目链接虽然不知道怎么做,但是AC还是没有问题的。大概就是循环n次,从m加到m-n/2 除了最后一个数,每个都加两次。#include int main(){ int n, m; while (scanf("%d %d", &m, &n) != EOF) { int ans = 0; int t = m; for (int i = n; i != 1; i -= 2) { ans += t*2; t--; } ans += t; pri... 阅读全文
posted @ 2013-06-03 19:45 xindoo 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 1.资源问题1-----机器分配问题F[I,j] = max(f[i-1,k]+w[i,j-k])2.资源问题2------01背包问题F[I,j] = max(f[i-1,j-v]+w,f[i-1,j]); 3.线性动态规划1-----朴素最长非降子序列F = max{f[j]+1}4.剖分问题1-----石子合并F[i,j] = min(f[i,k]+f[k+1,j]+sum[i,j]);5.剖分问题2-----多边形剖分F[I,j] = min(f[i,k]+f[k,j]+a[k]*a[j]*a);6.剖分问题3------乘积最大f[i,j] = max(f[k,j-1]*mult[k 阅读全文
posted @ 2013-06-03 10:19 xindoo 阅读(2104) 评论(0) 推荐(2) 编辑
摘要: A.Ilya and Bank AccountIlya得到了一个礼物,可以在删掉银行账户最后和倒数第二位的数字(账户有可能是负的),也可以不做任何处理。//codeforces 313A //2013-05-31-13.47#include #include using namespace std;int main(){ int n; scanf("%d", &n); if (n) { if (n >= 0) { printf("%d\n", n); } else { ... 阅读全文
posted @ 2013-05-31 13:50 xindoo 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 大概题意就是求最少添加多少个字符可以把长度为N的字符串编程回文串。则需要最少需要补充的字母数 = 原序列S的长度 — S和S'的最长公共子串长度S'为原串的逆串。关于求最长公共子串, 用到的是动态规划伪代码如下if( i ==0 || j == 0 ){ MaxLen(i, j) = 0 //两个空串的最长公共子序列长度当然是0}else if( s1[i] == s2[j] ) MaxLen(i, j) = MaxLen(i-1, j-1 ) + 1;else { MaxLen(i, j) = Max( MaxLen(i, j-1), MaxLen(i-1, j));}具体. 阅读全文
posted @ 2013-05-30 20:08 xindoo 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 题目链接//poj 2105//2013-05-01-21.10#include char s[34];int a[8] = {128, 64, 32, 16, 8, 4, 2, 1};int main(){ int n; scanf("%d", &n); while (n--) { scanf("%s", s); int ans = 0; int f = 1; for (int i = 0; i < 32; i++) { if (s[i] == '1') ... 阅读全文
posted @ 2013-05-27 21:06 xindoo 阅读(141) 评论(0) 推荐(0) 编辑
上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 21 下一页