摘要:
原题链接最小公倍数等于两数之积除以最大公约数。//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) * 阅读全文
摘要:
原题链接注意输出格式,每一组的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) ... 阅读全文
摘要:
原题链接#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" 阅读全文
摘要:
原题链接问题最后转化成求两个数的最大公约数,如果为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 阅读全文