http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1005
#include <stdio.h> int main() { int a, b, t, n; while(scanf("%d%d%d", &a, &b ,&n) != EOF) { if (a == 1) { for (t = 1; t <= n; t++) printf("fill A\npour A B\n"); printf("success\n"); continue; } t = 0; /* Current B is emplty */ while(t != n) { printf("fill A\npour A B\n"); t += a; if (t >= b) { t -= b; printf("empty B\npour A B\n"); } } printf("success\n"); } return 0; }
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1003
#include <stdio.h> #define bool int #define false 0 #define true 1 bool aTrue, bTrue; int judge(int m, int n, int p) { if (aTrue) return 0; if (m == 1 && n == 1) { aTrue = true; return 0; } if (n == 1) bTrue = true; while (p > 1) { if (m%p == 0) judge(m/p, n, p - 1); if (n%p == 0) judge(m, n/p, p - 1); p--; } return 0; } int main() { int a, b; while(scanf("%d%d", &a, &b) != EOF) { if (a < b) { int temp = a; a = b; b = temp; } aTrue = bTrue = false; judge(a, b, 100); if (!aTrue && bTrue) printf("%d\n", b); else printf("%d\n", a); } return 0; }
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1078
#include <stdio.h> int main() { int n; int i,j; while(scanf("%d", &n) && n) { int sign = 0; char c[30] = {0}; int base[17] = {0}; for (i = 2; i <= 16; i++) { int m = n; int len = 0; while (m) { c[len++] = m%i; m = m/i; } sign = 1; for (j = 0; j < len/2&&sign; j++) if (c[j] != c[len -j -1]) sign = 0; if (sign) base[i] = 1; } sign = 0; for (i = 2; i <= 16; i++) if (base[i] == 1) sign = 1; if (!sign) printf("Number %d is not a palindrom\n", n); else { printf("Number %d is palindrom in basis", n); for (i = 2; i <= 16; i++) if (base[i] == 1) printf(" %d", i); printf("\n"); } } return 0; }
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1067
#include <stdio.h> struct color { int R, G, B; }map[16]; int main() { int i = 0; for (i = 0; i < 16; i++) scanf("%d%d%d", &map[i].R, &map[i].G, &map[i].B); struct color c; while(scanf("%d%d%d", &c.R, &c.G, &c.B) && c.R >=0 ) { int index = 0; int min = 65535; for (i = 0; i < 16; i++) { int d = (c.R - map[i].R)*(c.R - map[i].R) + (c.G - map[i].G)*(c.G - map[i].G) + (c.B - map[i].B)*(c.B - map[i].B); if (min > d) { min = d; index = i; } } printf("(%d,%d,%d) maps to ", c.R, c.G, c.B); printf("(%d,%d,%d)\n", map[index].R, map[index].G, map[index].B); } return 0; }
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1058
#include <stdio.h> int main () { double a[6][6]; int b[13]; int n; int flag = 0; int cases; scanf("%d", &cases); while(cases--) { int i,j; if (flag) printf("\n"); flag = 1; for (i = 1; i <= 5; i++) for (j = 1; j <=5; j++) scanf("%lf", &a[i][j]); while(scanf("%d", &n) && n) { b[1] = 1; for (i = 2; i <= n+1; i++) scanf("%d", &b[i]); b[i] = 1; double m = 0; scanf("%lf", &m); for (i = 2; i <= n+2; i++) { m = m*a[b[i-1]][b[i]]; m = (int)(m*100+0.5); m /= 100; } printf("%.2lf\n", m); } } return 0; }
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1049
#include <stdio.h> #include <math.h> const double PI = 3.1415927; int main() { int n, i = 1; int year; double x, y, radius, area; scanf("%d", &n); while(n--) { scanf("%lf%lf", &x, &y); radius = x * x + y * y; area = PI * radius / 2.0; year = (int)ceil(area/50.0); printf("Property %d: ", i++); printf("This property will begin eroding in year %d.\n", year); } printf("END OF OUTPUT.\n"); return 0; }
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1045
#include <stdio.h> int main() { float c; while(scanf("%f", &c) && c !=0) { int i = 2; float fResult = 0; while (fResult < c) { fResult += 1.00/i; i++; } printf("%d card(s)\n", i - 2); } return 0; }
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1037
/* 1. M*N; M*N-1+sqrt(2); 2. scanf/printf 3. Judge if the number is even number (number%2 == 0) */ #include <stdio.h> int main() { int iCase; scanf("%d", &iCase); int i; for (i = 1; i <= iCase; i++) { int N, M; scanf("%d%d", &N, &M); printf("Scenario #%d:\n", i); printf("%d.", M*N); if(M&0x1 && N&0x1) printf("41"); else printf("00"); printf("\n\n"); } return 0; }
ID | ACM ID | Topic | Date |
6 | ZOJ1078: palindrom number(回文数) | ||
5 | ZOJ1067: ColreMeLess (颜色压缩) | ||
4 | ZOJ1058: Currency Exchange | ||
3 | ZOJ1049: houseboat解答。 | ||
2 | ZOJ1045 | Handover | |
1 | ZOJ: 1037 | Gridland | 2013.3.4 |