2014年2月11日
摘要: 原题链接考察对字符串的操作。将各个字符出现的次数保存到数组中,重复出现的赋值为 ‘.’, 再将数组降序排序,后面就简单了。附ac代码:#include #include #include #include int cmp(const void *a, const void *b){ return *(int *)b - *(int *)a;}int f(int n){ //判断素数 if(n < 2) return 0; for(int i = 2; i <= sqrt(n); ++i) if(n % i == 0) return 0; return 1;}int main(){ 阅读全文
posted @ 2014-02-11 16:43 长木Qiu 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 原题链接难点是用节点表示学生信息,并增加一个变量保存奖学金金额。附ac代码:#include #include struct Node{ char name[21], gov[2], min[2]; int test, ctest, paper, scholarship;};struct node{ int maxsch, subscript;};void judge(Node *stu){ //一等奖学金 if(stu->test > 80 && stu->paper) stu->scholarship += 8000; //二等奖学金 if(stu- 阅读全文
posted @ 2014-02-11 16:04 长木Qiu 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 原题链接简单题附ac代码:#include struct Unhappy{ int day, time;};int main(){ Unhappy stu; int t, a, b; scanf("%d", &t); while(t--){ stu.time = stu.day = 0; int i = 0; while(i++ stu.time) stu.time = a + b - 8, stu.day = i; } printf("%d\n", stu.day); } return 0;} 阅读全文
posted @ 2014-02-11 15:11 长木Qiu 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 原题链接简单题。附ac代码:#include int main(){ int t, a[10], i, height, count; scanf("%d", &t); while(t--){ for(i = count = 0; i != 10; ++i) scanf("%d", &a[i]); scanf("%d", &height); height += 30; for(i = 0; i != 10; ++i) if(height >= a[i]) ++count; printf("%d\n 阅读全文
posted @ 2014-02-11 14:54 长木Qiu 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 原题链接这题真奇葩,在输出的行末加了回车竟然WA,把回车换成空格就ac,真无语,史上最烂题。附ac代码: #include #include int a[1001];int cmp(const void *a, const void *b){ return *(int *)a - *(int *)b;}int main(){ int n, t, count; scanf("%d", &n); int i = 0; count = n; while(i != n) scanf("%d", &a[i++]); qsort(a, n, size 阅读全文
posted @ 2014-02-11 14:27 长木Qiu 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 原题链接简单题。附ac代码:#include int len( int n ){ int i = 1; while( n != 1 ){ if( n & 1 ) n = 3 * n + 1; else n >>= 1; ++i; } return i;}int main(){ int i, j, maxlen, ii, jj; while( scanf( "%d%d", &i, &j ) == 2 ){ i maxlen ) ... 阅读全文
posted @ 2014-02-11 13:59 长木Qiu 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 原题链接这题和hdu 1032一样,令人郁闷的是在hdu ac的代码拿到nyoj就TLE了,然后果断加上打表,就过了。附ac代码:#include #define MAX 10001int a[MAX];int len( int n ){ int i = 1; while( n != 1 ){ if( n & 1 ) n = 3 * n + 1; else n >>= 1; ++i; } return i;}void CountA(){ for(int i = 1; i != MAX;... 阅读全文
posted @ 2014-02-11 13:55 长木Qiu 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 原题链接一道略有技巧性的简单题。附ac代码:#include #define MAX 101int a[MAX][MAX];int main(){ int n, x, y, count = 1; scanf("%d", &n); a[x = 0][y = n - 1] = 1; while(count = 0 && !a[x][y - 1]) //向左填 a[x][--y] = ++count; while(x - 1 >= 0 && !a[x - 1][y]) //向上填 a[--x][y] = ++count; while( 阅读全文
posted @ 2014-02-11 11:15 长木Qiu 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 原题链接标准水题。ac代码:#include int main(){ int a[3][3], t; scanf("%d", &t); while(t--){ for(int i = 0; i != 3; ++i) for(int j = 0; j != 3; ++j) scanf("%d", &a[j][i]); for(int i = 0; i != 3; ++i){ for(int j = 0; j != 3; ++j){ printf("%d", a[i][j]); if(j != 2) putchar( 阅读全文
posted @ 2014-02-11 01:00 长木Qiu 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 原题链接简单题,但是要注意特殊情况,比如0+0, .123+.123等。附ac代码:#include #include #define MAX 400 + 10char a0[MAX], b0[MAX], s[MAX], aa[MAX], bb[MAX], ss0[MAX]; //aa保存整数,a保存小数int main(){ char *dot; while( scanf( "%s%s", a0, b0 ) == 2 ){ char *a = a0, *b = b0, *ss = ss0; aa[0] = bb[0] = '0'; //留着进位 ... 阅读全文
posted @ 2014-02-11 00:36 长木Qiu 阅读(109) 评论(0) 推荐(0) 编辑