2014年2月15日
摘要: 原题链接标记法。经典题,不需要去重。附ac代码:#include int a[501], b[501];int main(){ int n, i, t, j, k; while(scanf("%d", &n), n){ for(i = 1; i = 1; --k){ if(b[k]) continue; if(i) printf("%d", a[k]), i = 0; else printf(" %d", a[k]); } printf("\n"); } return 0;} 阅读全文
posted @ 2014-02-15 22:52 长木Qiu 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 原题链接经典题。这题可以从最基本的情况开始推,可以发现是斐波那契数列,剩下的就简单了。附ac代码:#include int a[41] = {1, 2, 3, 5};int main(){ int t, n, i; for(i = 4; i != 41; ++i) a[i] = a[i - 1] + a[i - 2]; scanf("%d", &t); while(t-- && scanf("%d", &n)) printf("%d\n", a[n]); return 0;} 阅读全文
posted @ 2014-02-15 18:28 长木Qiu 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 原题链接简单题。附ac代码:#include #include int cmp(const void *a, const void *b){ return *(int *)a - *(int *)b;}int main(){ int t, n, *a, i; scanf("%d", &t); while(t-- && scanf("%d", &n)){ a = (int *)malloc(sizeof(int) * n); i = 0; while(i != n) scanf("%d", &a[ 阅读全文
posted @ 2014-02-15 11:53 长木Qiu 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 原题链接烂题。冒泡可行但违背了原题的意思。附ac代码:#include #include int main(){ int n, *a, count, i, j, t; while(scanf("%d", &n) == 1){ i = count = 0; a = (int *)malloc(sizeof(int) * n); while(i a[j]){ t = a[i], a[i] = a[j], a[j] = t; ++count; } printf("%d\n", count); free(a); } return 0;}附原WA代码 #i 阅读全文
posted @ 2014-02-15 11:41 长木Qiu 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 原题链接水题。附ac代码:#include #include int a[1001];void Count(){ int i, j, t = (int)sqrt(1001); for(i = 2; i = 1000000) s %= 1000000; } printf("%d\n", s); } return 0;} 阅读全文
posted @ 2014-02-15 11:10 长木Qiu 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 原题链接水题。附ac代码:#include char s[12];char f(char c){ switch(c){ case 'a': case 'b': case 'c': return '2'; case 'd': case 'e': case 'f': return '3'; case 'g': case 'h': case 'i': return '4'; case 'j': 阅读全文
posted @ 2014-02-15 10:57 长木Qiu 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 原题链接水题。附ac代码:#include #include char s[50], *a[] = {"bowl", "knife", "fork", "chopsticks"};int main(){ int t, i; while(scanf("%d", &t) == 1){ while(t-- && scanf("%s", s)) for(i = 0; i != 4; ++i) if(strcmp(s, a[i]) == 0) printf(&q 阅读全文
posted @ 2014-02-15 10:38 长木Qiu 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 原题链接原式可以化成(i + 1) * (j + 1) = N + 1; 因为i, j > 0, 所以问题转换成了求N + 1的大于等于2的所有因子个数(不包括本身)。比如N = 5,则因子为2, 3,但是只属于一种情况,因为2*3 = 3*2.。要用sqrt,否则易超时。附ac代码:#include #include int main(){ int t, count, m; long long n, i; scanf("%d", &t); while(t-- && scanf("%lld", &n)){ count 阅读全文
posted @ 2014-02-15 10:23 长木Qiu 阅读(133) 评论(0) 推荐(0) 编辑