摘要:
原题链接#include struct Node{ int begin, end;};Node a[201];int p[401];int main(){ int t, n, i, temp, count, j; scanf("%d", &t); while(t--){ scanf("%d", &n); for(i = 0; i != n; ++i){ scanf("%d%d", &a[i].begin, &a[i].end); if(a[i].begin > a[i].end){ temp =
阅读全文
posted @ 2014-03-11 22:33
长木Qiu
阅读(102)
推荐(0)
编辑
摘要:
原题链接思路:比如说13的阶乘中有多少个3.13!=1*2*3*...*6*...9*...12;其中有多少个数能被3整除呢?答案是13/3=4个。但是答案却是5,为什么,因为9里面有2个3所以是4个.若是100!里面有多少个5?首先看里面有多少个数能被5整除,答案是100/5=20;再看有多少个数能被5*5整除,答案是100/25=(100/5)上面的结果/5,直到除到结果小于5为止,把每个式子的结果相加即为答案。#include int main(){ int t, a, b, count; scanf("%d", &t); while(t--){ scanf(
阅读全文
posted @ 2014-03-11 21:21
长木Qiu
阅读(156)
推荐(0)
编辑
摘要:
原题链接注意要用__int64存和。//2014-3-11 20:31:42#include int main(){ int t, n, max, a; __int64 s; scanf("%d", &t); while(t-- && scanf("%d", &n)){ s = max = 0; for(int i = 0; i != n; ++i){ scanf("%d", &a); if(a > max) max = a; s += a; } if(s - max >= max
阅读全文
posted @ 2014-03-11 20:38
长木Qiu
阅读(157)
推荐(0)
编辑
摘要:
原题链接//二分法2014-3-11 19:10:15#include int f(int a, int b){ if(b == 1) return a; int s = f(a, b / 2); if(b & 1) return s * s * a % 1000; else return s * s % 1000;}int main(){ int a, b; while(scanf("%d%d", &a, &b), a || b){ a %= 1000; printf("%d\n", f(a, b)); } return 0;}
阅读全文
posted @ 2014-03-11 19:16
长木Qiu
阅读(150)
推荐(0)
编辑
摘要:
原题链接很经典的一道题,开始想着用二分法,结果超时,后来发现了规律,就搞定啦。//找规律2014-3-11 18:40:19#include #include char *sam[] = {"0", "1", "2486", "3971", "46", "5", "6", "7931", "8426", "91"};int main(){ int t, n, time; scanf("%
阅读全文
posted @ 2014-03-11 18:52
长木Qiu
阅读(123)
推荐(0)
编辑
摘要:
原题链接//2014-3-11 09:16:50#include #define MAX 1000000int a[MAX] = {1, 2};int main(){ int n; for(n = 2; n != MAX; ++n) a[n] = (a[n - 1] + a[n - 2]) % 3; while(scanf("%d", &n) == 1) printf(a[n] ? "no\n" : "yes\n"); return 0;}优化好的代码://2014-3-11 09:29:47#include int main
阅读全文
posted @ 2014-03-11 09:20
长木Qiu
阅读(128)
推荐(0)
编辑