http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3403

/* 这样的水题把我卡的好惨的,看来不够细心啊 */ #include #include #include typedef long long LL; using namespace std; const long long year = 18382; //LL ye[] = {1, 9, 36, 100, 225, 441, 784, 1296, 2025, 3025, 4356, 6084}; int mon[13]; bool Leap(int y) { if (y % 11 == 0) return true; return false; } void Month(int y) { if (Leap(y)) mon[1] = 2; else mon[1] = 1; int temp = (y % 12) + 1; for (int i = 2; i <= temp; i++) mon[i] = i * i * i; } long long Fun(int y) { long long sum; // if (Leap(y)) // sum = 2; // else sum = 1; int temp = (y % 12) + 1; for (int i = 2; i <= temp; i++) sum += i * i * i; //printf("%lld/n", sum); return sum; } long long Sum(int m, int d, int y) { if(y == 0) return (long long ) d; int temp = (y - 1) % 12; long long ans = 2; if (y > 12) { ans += ( (y - 1) / 12) * year; } ans += (y - 1)/ 11; for (int i = y - temp ; i < y; i++) ans += Fun(i); Month(y); // 就因为这个函数写错了,闰月没有判,一直wrong for (int i = 1; i < m; i++) ans += mon[i]; ans += d; return ans; } int main() { int m1, d1, y1; int m2, d2, y2; while (scanf("%d-%d-%d %d-%d-%d", &m1, &d1, &y1, &m2, &d2, &y2) != EOF) { /* long long ans = 0; for(int i = 1; i <= 12; i++) ans += Fun(i); printf("%lld/n", ans); */ /// scanf("%d-%d-%d", &m2, &d2, &y2); long long sum1 = Sum(m1, d1, y1); long long sum2 = Sum(m2, d2, y2); //printf("%lld %lld/n", sum1, sum2); printf("%lld/n", (long long)(fabs(1.0 * sum1 - sum2 ) + 1 ) ); } return 0; } /* 1-1-0 1-1-1 1-1-0 1-1-12 1-1-0 1-1-1000000000 3 18385 1531924236444 */  

你可能感兴趣的:(ACM,水题之路,fun)