上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 17 下一页
  2014年2月23日
摘要: ACM比赛经验:推荐此篇文章打印,与模板放在一起。1. 比赛中评测会有些慢,偶尔还会碰到隔10分钟以上才返回结果的情况,这段时间不能等结果,必须开工其他题,如果WA,两道题同时做。交完每道题都要先打印。2. 比赛时发的饭不是让你当时就吃的,那是给你赛后吃的。基本上比赛中前几名的队都没人吃,除非领先很多。3. 很多选手,尤其是第一次参加比赛的,到一个新环境,全当旅游了,参观的参观,找同学的找同学,玩玩乐乐就把正事抛到脑后了,结果比赛自然没什么好成绩,这样的例子太多了。所以到参赛地后要时刻不忘自己是来比赛的,好好休息、备战。4. 参赛前一天要睡10个小时以上,非常有助于保持比赛中的精力,很多时候比 阅读全文
posted @ 2014-02-23 17:53 长木Qiu 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 用到 1.同余定理: (a + b) % c == (a % c + b % c) % c; 2. k * 10^m % 9 == k % 9。综上,设a == b *100 + c * 10 + d; A == b + c + d,则a % 9 == (b*100 % 9 + c*10 % 9 + d % 9) % 9 == (b + c + d) % 9 % 9 == (b + c + d) % 9 == A % 9;。#include int main(){ int t; scanf("%d", &t); long long a, b; while(t-- & 阅读全文
posted @ 2014-02-23 17:41 长木Qiu 阅读(100) 评论(0) 推荐(0) 编辑
  2014年2月22日
摘要: 水。#include #include bool f(int n){ int t = (int)sqrt(n); for(int i = 2; i <= t; ++i) if(n % i == 0) return 0; return 1;}int main(){ int a[30] = {0, 3, 7}, i; for(i = 3; i != 30; ++i) a[i] = a[i - 1] + a[i - 2]; while(scanf("%d", &i), i != -1) printf(f(a[i]) == 0 ? "No\n" : 阅读全文
posted @ 2014-02-22 21:40 长木Qiu 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 直接打表。 #include #define MAX 500000 + 2int a[MAX];void count(){ int t = MAX / 2, i, j; for(i = 1; i != t; ++i) for(j = i * 2; j <= MAX; j += i) a[j] += i;}int main(){ int t, n; count(); scanf("%d", &t); while(t-- && scanf("%d", &n)) printf("%d\n", a[n]) 阅读全文
posted @ 2014-02-22 20:58 长木Qiu 阅读(130) 评论(0) 推荐(0) 编辑
  2014年2月21日
摘要: 原题链接注意任何数的0次方都为1.#include int main(){ int a, b; while(scanf("%d%d", &a, &b) == 2){ if(b == 0){ printf("1\n"); continue; } b = (b - 1) % 4 + 1; int t = a = a % 10; for(int i = 1; i < b; ++i) a *= t; printf("%d\n", a % 10); } return 0;} 阅读全文
posted @ 2014-02-21 23:06 长木Qiu 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 原题链接#include int main(){ int n, a, b, t; while(scanf("%d", &n) == 1){ a = b = 0; while(n-- && scanf("%d", &t)) if(t & 1) ++b; else ++a; printf("%d\n", b & 1 ? b : a); } return 0;} 阅读全文
posted @ 2014-02-21 16:14 长木Qiu 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 原题链接这题坑了不少人,要考虑n为负的情况。好在不管它是正是负总归是等差数列吧,这样规律就明显了,直接用(首项 + 末项)* 项数 / 2;由于n的范围在10000之内,所以不需要考虑溢出的情况。关键是项数 = 首尾差的绝对值 + 1;#include #include int main(){ int n; while(scanf("%d", &n) == 1) printf("%d\n", (abs(n - 1) + 1) * (1 + n) / 2); return 0;} 阅读全文
posted @ 2014-02-21 00:17 长木Qiu 阅读(122) 评论(0) 推荐(0) 编辑
  2014年2月20日
摘要: 原题链接复杂度O(logn);#include #define mod 10003int f(int a, int n){ if(n == 0) return 1 % mod; if(n == 1) return a % mod; int t = f(a, n / 2); t = t * t % mod; if(n & 1) return t * a % mod; return t;}int main(){ int t, a, n, s, i; scanf("%d", &t); while(t-- && scanf("%d%d&qu 阅读全文
posted @ 2014-02-20 22:58 长木Qiu 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 原题链接string.find(); 和 string.replace();的用法。#include #include using namespace std;int main(){ string str; int p; while(getline(cin, str)){ p = str.find("you"); while(p != string::npos){ str.replace(p, 3, "we"); p = str.find("you", p + 1); } cout << str << endl 阅读全文
posted @ 2014-02-20 10:02 长木Qiu 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 原题链接strtok + sort就搞定了。#include #include #include using namespace std;#define MAX 1000 + 2char str[MAX];int a[MAX];int main(){ int count; char *p; while(scanf("%s", str) == 1){ count = 0; p = strtok(str, "5"); while(p != NULL){ sscanf(p, "%d", &a[count++]); p = strto 阅读全文
posted @ 2014-02-20 09:27 长木Qiu 阅读(138) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 17 下一页