上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 17 下一页
  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) 编辑
  2014年2月14日
摘要: 原题链接这题做得真心纠结,RE两次才ac。思路是每次相乘后都取余,以余数为索引将指数存到数组中,若余数相同的存在,则直接返回当前指数与对应数组元素的和。经典题。附ac代码:#include #include int sign[1001]; //索引int f(long long k){ memset(sign, 0, sizeof(sign)); long long t; int i = 1, j; t = k; while(k < 1000){ k *= t; ++i; } sign[k %= 1000] = i++; for(j = 1; j <= 1001; ++j, ++i 阅读全文
posted @ 2014-02-14 22:21 长木Qiu 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 原题链接经典题,模拟求余。附ac代码:#include #include #define MAX 1000000 + 2char s[MAX];//模拟取余int Simu(int n){ int t = 0, len = strlen(s); for(int i = 0; i != len; ++i){ t = t * 10 + s[i] - '0'; t %= n; } return t;}int main(){ int t, x; scanf("%d", &t); while(t-- && scanf("%s" 阅读全文
posted @ 2014-02-14 20:18 长木Qiu 阅读(174) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 17 下一页