2014年2月12日
摘要: 原题链接盗梦空间这个电影我看了三遍。good!附ac代码:#include #include double cal(int t, int lev){ //接受分钟,返回秒 double s = t; s *= 60; while(lev--) s /= 20; return s;}int main(){ int t, n, lev, temp; double time; char s[5]; scanf("%d", &t); while(t-- && scanf("%d", &n)){ lev = 0; time = 0; 阅读全文
posted @ 2014-02-12 21:43 长木Qiu 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 原题链接大水题。附ac代码:#include #include int cmp(const void *a, const void *b){ return *(int *)a - *(int *)b;}int main(){ int t, n; scanf("%d", &t); while(t-- && scanf("%d", &n)){ int *a = (int *)malloc(sizeof(int) * n); int i = 0; while(i < n) scanf("%d", &am 阅读全文
posted @ 2014-02-12 21:18 长木Qiu 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 原题链接简单题。附ac代码:#include int T[302];int main(){ int t, n, s, i, j = 1; for(i = 1; i != 302; ++i) T[i] = T[i - 1] + i; scanf("%d", &t); while(t-- && scanf("%d", &n)){ s = 0; for(i = 1; i <= n; ++i) s += i * T[i + 1]; printf("%d %d %d\n", j++, n, s); } re 阅读全文
posted @ 2014-02-12 21:04 长木Qiu 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 原题链接开始把题意看错了,把数组多开了100000000倍,结果直接运行不了,运行框都不出来了...⊙﹏⊙b汗附ac代码:#include #include #define MAX 11char a[MAX], b[MAX];int main(){ int t; long long s; scanf("%d", &t); while(t-- && scanf("%s%s", a, b)){ s = 0; int m = strlen(a), n = strlen(b); for(int i = 0; i != m; ++i){ i 阅读全文
posted @ 2014-02-12 20:30 长木Qiu 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 原题链接这题要打表,否则容易超时。附ac代码:#include #include int main(){ int n, m, i, x, y; scanf("%d%d", &n, &m); int *a = (int *)malloc(sizeof(int) * (n + 1)); for(i = 1, a[0] = 0; i <= n; ++i){ scanf("%d", &a[i]); a[i] += a[i - 1]; } while(m-- && scanf("%d%d", &am 阅读全文
posted @ 2014-02-12 18:22 长木Qiu 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 原题链接这题只需要将所有物品按照降序排序,然后从上往下取就行,附ac代码:#include #include struct Node{ int v, w;};int cmp(const void *a, const void *b){ return (*(Node *)b).v - (*(Node *)a).v; //按单位价值降序}int main(){ int t, s, v, w, m; Node a[11], sum; scanf("%d", &t); while(t-- && scanf("%d%d", &s, 阅读全文
posted @ 2014-02-12 17:20 长木Qiu 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 原题链接这题的技巧是:能被3整除的自然数各位的和能被3整除,9也同理。再也不把strlen放进循环里了。这次放进去直接超时了我去。附ac代码:#include #include #define MAX 1000000 + 2char s[MAX];int main(){ int t, sum; scanf("%d", &t); while(t-- && scanf("%s", s)){ sum = 0; int len = strlen(s); for(int i = 0; i != len; ++i) sum += s[i] - 阅读全文
posted @ 2014-02-12 16:28 长木Qiu 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 原题链接简单题。解法可参考NYOJ 88附ac代码:#include long long f(int a, int b, int c){ if(a == 1) return 1 % c; if(b == 1) return a % c; long long s = f(a, b / 2, c); s = s * s % c; if(b & 1) return s * a % c; return s;}int main(){ int a, b, c, t; scanf("%d", &t); while(t-- && scanf("%d 阅读全文
posted @ 2014-02-12 15:46 长木Qiu 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 原题链接简单题。附ac代码:#include #include int a[100];int cmp(const void *a, const void *b){ return *(int *)a - *(int *)b;}struct Node{ int a, n;};int main(){ int t, n; Node max; scanf("%d", &t); while(t-- && scanf("%d", &n)){ int i; for(i = 0; i != n; ++i) scanf("%d&qu 阅读全文
posted @ 2014-02-12 15:13 长木Qiu 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 原题链接很经典的一道题。阶乘和有个特点就是前n项和总比第n+1项小,这题就需要这个性质。附ac代码:#include int a[11];int jie(int n){ //计算阶乘 int i, s = 1; for(i = 2; i = a[i]) n -= a[i]; n == 0 ? printf("Yes\n") : printf("No\n"); } return 0;} 阅读全文
posted @ 2014-02-12 14:37 长木Qiu 阅读(159) 评论(0) 推荐(0) 编辑