上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页
  2014年2月17日
摘要: 原题链接稳定排序。附ac代码:#include #include #include using namespace std;int main(){ vector vec; int n, i, j, count = 1, m; string t; while(cin >> n, n){ for(i = 0; i != n; ++i){ cin >> t; vec.push_back(t); } //排序 m = n; while(m > 1){ for(j = 0; j vec[j + 1].length()) t = vec[j], vec[j] = vec... 阅读全文
posted @ 2014-02-17 15:31 长木Qiu 阅读(152) 评论(0) 推荐(0) 编辑
  2014年2月16日
摘要: 原题链接参考:百科:约瑟夫问题经典题。附ac代码:#include int main(){ int t, m, n, f; scanf("%d", &t); while(t-- && scanf("%d%d", &n, &m)){ f = 0; for(int i = 2; i <= n; ++i) f = (f + m) % i; printf("%d\n", f + 1); } return 0;} 阅读全文
posted @ 2014-02-16 19:57 长木Qiu 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 原题链接注意0和1的情况。经典题,简单题。附ac代码:#include int a[20];int main(){ int n, i, count; while(scanf("%d", &n) == 1){ i = 9; count = 0; if(n == 0){ printf("10\n"); continue; } if(1 == n){ printf("1\n"); continue; } while(i > 1){ if(n % i == 0){ a[count++] = i; n /= i; continue 阅读全文
posted @ 2014-02-16 15:34 长木Qiu 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 水。附ac代码:#include #include char s[100];bool cmp(int len){ for(int i = 0, j = len - 1; i < j; ++i, --j) if(s[i] != s[j]) return 0; return 1; }int main(){ int t, len; scanf("%d", &t); while(t-- && scanf("%s", s)){ len = strlen(s); while(!(len & 1) && cmp(l 阅读全文
posted @ 2014-02-16 14:57 长木Qiu 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 水。附ac代码:#include int main(){ int t, a[3][3]; scanf("%d", &t); while(t--){ for(int i = 0; i != 3; ++i) for(int j = 0; j != 3; ++j) scanf("%d", &a[i][j]); for(int i = 0; i != 3; ++i){ printf("%d", a[0][i]); for(int j = 1; j != 3; ++j) printf(" %d", a[j][ 阅读全文
posted @ 2014-02-16 14:39 长木Qiu 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 原题链接水。附ac代码:#include int main(){ int t, k, n; double s; scanf("%d", &t); while(t-- && scanf("%d", &k)){ for(s = 0, n = 1; s <= k; ++n) s += 1.0 / n; printf("%d\n", n - 1); } return 0;} 阅读全文
posted @ 2014-02-16 14:29 长木Qiu 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 原题链接简单题。附ac代码:#include #include int cmp(const void *a, const void *b){ return *(int *)a - *(int *)b;}int main(){ int t, n, i, *a, flag; scanf("%d", &t); while(t-- && scanf("%d", &n)){ a = (int *)malloc(sizeof(int) * n); for(i = 0; i != n; ++i) scanf("%d" 阅读全文
posted @ 2014-02-16 14:18 长木Qiu 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 原题链接简单题。附ac代码:#include #include struct node{ int num, time;};int cmp(const void *a, const void *b){ return *(int *)a - *(int *)b;}int main(){ node max; int t, n, i, temp, *a, j; scanf("%d", &t); while(t-- && scanf("%d", &n)){ a = (int *)malloc(sizeof(int) * n); fo 阅读全文
posted @ 2014-02-16 13:44 长木Qiu 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 原题链接最多49一循环,关键是找到循环起点和循环次数,循环起点不一定为f[1],所以要把数组适当开大点。之前一直把循环起点当成1了。所以老是WA。%>_int f[100]; int main(){ int a, b, n, i, j, cir; while(scanf("%d%d%d", &a, &b, &n), a || b || n){ f[1] = f[2] = 1; cir = 0; for(i = 3; i != 100; ++i){ f[i] = (a * f[i - 1] + b * f[i - 2]) % 7; for(j = 阅读全文
posted @ 2014-02-16 12:14 长木Qiu 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 原题链接这题刚开始做的时候脑海里乱成了一锅粥,%>_#include char buf[101], buff[101], a[101], b[11], c[11];int strco(int i, int j, char str[]){ int k, kk; for(k = i, kk = 0; k jj ? ii : jj), buf); min.ok = 1; continue; } temp = (ii > jj ? ii : jj) - (i jj ? ii : jj, buf); else if(temp == m... 阅读全文
posted @ 2014-02-16 11:34 长木Qiu 阅读(134) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页