2014年2月28日
摘要: 原题链接这题难在找到题中隐含的递推关系,假设当n = k的时候有s中情况,那么当n = k + 1时,若新增加的一元钱化成两张5角,那么一共有s种情况,再把其中的一张5角化掉,增加(n * 10 - 5)/ 2 +1种情况,再化掉剩下的一张5角,增加(n*10/2)+1种情况,整理可得n = k + 1时,结果为s +(n * 10 - 5)/ 2 +1 +(n*10/2)+1 = s + n * 10 - 1种情况,递推关系出来了,剩下的就好办了。直接打表。#include int a[101] = {0, 10};int main(){ int t, n; for(n = 2; n != 阅读全文
posted @ 2014-02-28 23:30 长木Qiu 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 原题链接这题很简单,但是做得我想哭%>_#include char *a[] = {"one", "two", "three"}, str[6];int cmp(char s[]){ int count = 0, len = strlen(str); for(int i = 0; i != len; ++i) if(s[i] != str[i]) ++count; return count;}int main(){ int t, i, x; scanf("%d", &t); while(t-- &am 阅读全文
posted @ 2014-02-28 22:45 长木Qiu 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 原题链接在没有更好的方法前,最笨的方法就是最好的方法。#include #include int cmp(const void *a, const void *b){ int aa = *(int *)a, bb = *(int *)b; int i = 0, j = 0; while(aa){ i = i * 10 + aa % 10; aa /= 10; } while(bb){ j = j * 10 + bb % 10; bb /= 10; } return i - j;}int main(){ int t, a, b, *vec; scanf("%d", & 阅读全文
posted @ 2014-02-28 19:39 长木Qiu 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 原题链接险过代码:#include #define MAX 1000000 + 2int a[MAX] = {0, 1, 2};bool Judge(int n){ while(n){ if(n % 10) { n /= 10; continue; } return false; } return true;}int main(){ int n, i; for(i = 3; i != MAX; ++i) if(Judge(i)) a[i] = a[i - 1] + 1; else a[i] = a[i - 1]; while(scanf("%d", &n) == 1 阅读全文
posted @ 2014-02-28 16:03 长木Qiu 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 原题链接还以为要用什么数学技巧否则会超时呢,结果没想到可以直接暴力求解。。#include #define mod 1314520int f[270] = {1, 1};int main(){ int n, a, b; for(n = 2; n != 270; ++n) f[n] = (f[n - 1] + f[n - 2]) % mod; while(scanf("%d", &n) == 1){ a = b = 0; while(n){ if(n & 1) ++a; else ++b; n >>= 1; } printf("%d\n& 阅读全文
posted @ 2014-02-28 15:22 长木Qiu 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 原题链接#include #include #include #include #include #define MAX 5000 + 2using namespace std;char s[MAX];int main(){ vector vec; int t; char *p; while(scanf("%s", s) == 1){ p = strtok(s, "5"); if(p == NULL){ printf("0\n"); continue; } while(p != NULL){ sscanf(p, "%d&qu 阅读全文
posted @ 2014-02-28 09:06 长木Qiu 阅读(98) 评论(0) 推荐(0) 编辑