上一页 1 2 3 4 5 6 7 8 ··· 17 下一页
  2014年3月11日
摘要: 原题链接最小公倍数等于两数之积除以最大公约数。//2014-3-11 09:03:09#include int gcd(int a, int b){ int t; while(b){ t = a % b; a = b; b = t; } return a;}int main(){ int t, n, a, s; scanf("%d", &t); while(t--){ scanf("%d", &n); s = 1; while(n--){ scanf("%d", &a); s = s / gcd(s, a) * 阅读全文
posted @ 2014-03-11 09:10 长木Qiu 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 原题链接注意输出格式,每一组的case都要重新开始计数。//模拟//2014-3-11 08:19:16#include int main(){ int t, n, m, a, b, count, time; scanf("%d", &t); while(t--){ time = 1; while(scanf("%d%d", &n, &m), n || m){ for(a = 1, count = 0; a < n - 1; ++a) for(b = a + 1; b < n; ++b) ... 阅读全文
posted @ 2014-03-11 08:51 长木Qiu 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 原题链接#include char buf[10001];int main(){ int t; char *p, ch; scanf("%d\n", &t); while(t--){ buf[0] = getchar(); p = buf + 1; while((ch = getchar()) != '\n'){ if(ch - 1 == *(p - 1) || ch - 2 == *(p - 1)) --p; else *p++ = ch; } printf(p == buf? "Yes\n": "No\n" 阅读全文
posted @ 2014-03-11 08:43 长木Qiu 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 原题链接问题最后转化成求两个数的最大公约数,如果为1就YES.#include int main(){ int step, mod, t; while(scanf("%d%d", &step, &mod) == 2){ printf("%10d%10d", step, mod); while(mod){ t = step % mod; step = mod; mod = t; } printf(" %s\n\n", step == 1? "Good Choice": "Bad Choice 阅读全文
posted @ 2014-03-11 07:59 长木Qiu 阅读(145) 评论(0) 推荐(0) 编辑
  2014年3月10日
摘要: 原题链接略坑的一道题。#include char str[1000];int f(int n){ int s = 0; while(n){ s += n % 10; n /= 10; } return s;}int main(){ int n, s; while(scanf("%s", str), str[0] - '0'){ s = 0; for(int i = 0; str[i] != '\0'; ++i) s += str[i] - '0'; while(s > 9) ... 阅读全文
posted @ 2014-03-10 22:32 长木Qiu 阅读(123) 评论(0) 推荐(0) 编辑
  2014年3月9日
摘要: 原题链接#include #include #define MAX 1001int a[MAX][MAX];int main(){ int t, n, max, count, i, j; scanf("%d", &t); while(t--){ scanf("%d", &n); max = (1 + n) * n / 2; count = 0; a[i = 1][j = 1] = ++count; while(count 1){ if(a[i + 1][j - 1] == 0) a[++i][--j] = ++count; else br 阅读全文
posted @ 2014-03-09 00:07 长木Qiu 阅读(159) 评论(0) 推荐(0) 编辑
  2014年3月8日
摘要: 原题链接stable_sort函数的用法。#include #include #include #include using namespace std;struct Node{ int num, sco; string name;};bool cmp(Node a, Node b){ return a.sco > b.sco;}int main(){ int t, n; Node stu; cin >> t; while(t--){ cin >> n; vector vec; while(n--){ cin >> stu.num >> s 阅读全文
posted @ 2014-03-08 23:03 长木Qiu 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 原题链接这个OJ的int不是32位的,所以坑了不少人,换成unsigned long long就行了。#include int main(){ unsigned long long t, n, a, b, d, i, j, oka; scanf("%lld", &t); while(t--){ scanf("%lld", &n); oka = b = d = 0; a = i = 1; for(j = 1; j <= 32; ++j){ if(n & i){ if(!oka) oka = 1; ++d; b = 0; }el 阅读全文
posted @ 2014-03-08 22:43 长木Qiu 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 原题链接(a-b)%c = (a%c - b%c)%c#include #include char str[105];int main(){ int c, len, a, i; while(scanf("%s", str), str[0] != '0'){ len = strlen(str); if(len == 1){ printf("0\n"); continue; } c = str[len - 1] - '0'; str[len - 1] = '\0'; if(len < 10){ sscan 阅读全文
posted @ 2014-03-08 22:04 长木Qiu 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 原题链接#include //#include int main(){ int a, b, c, count = 0; char ch, sign, s[5]; while(scanf("%d%c%d=%s", &a, &sign, &b, s) != EOF){ if(s[0] == '?') continue; if(sign == '+') c = a + b; else c = a - b; a = ch = 0; for(b = 0; s[b] != '\0'; ++b){ if(s[b] = 阅读全文
posted @ 2014-03-08 12:51 长木Qiu 阅读(137) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 17 下一页