码迷,mamicode.com
首页 > 其他好文 > 详细

真是日了狗了

时间:2015-06-22 16:12:00      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:

想退出ACM了

 

ZOJ 3573 Under Attack

两个值最大的位置居然可以相同...

技术分享
 1 #include <cstdio>
 2 #include <cstring>
 3 #include <algorithm>
 4 using namespace std;
 5 
 6 const int N = 15000 + 10;
 7 int A[N], num[N];
 8 
 9 int main() {
10     int n, L, R, x;
11     while (scanf("%d", &n) != EOF) {
12         memset(A, 0, sizeof(A));
13         memset(num, 0, sizeof(num));
14         while (scanf("%d%d%d", &L, &R, &x) != EOF) {
15             if (L != -1) {
16                 A[L] += x;
17                 A[R+1] -= x;
18             } else {
19                 int tep = 0;
20                 for (int i = 0; i <= n; i++) {
21                     tep += A[i];
22                     num[i] += tep;
23                 }
24                 int pos1 = 0, pos2 = 0;
25                 int maxx = 0;
26                 for (int i = 0; i <= n; i++) {
27                     if (num[i] > maxx) {
28                         maxx = num[i];
29                         pos1 = i;
30                     }
31                 }
32                 for (int i = n; i >= 0; i--) {
33                     if (num[i] == maxx) {
34                         pos2 = i;
35                         break;
36                     }
37                 }
38                 printf("%d %d\n", pos1, pos2);
39                 break;
40             }
41         }
42     }
43     return 0;
44 }
View Code

 

ZOJ 3574 Under Attack II

ZOJ 3576 Count the Length

ZOJ 3594 Sexagenary Cycle

没有公元0年...所以负数的年份要+1,

技术分享
 1 #include <cstdio>
 2 #include <cstring>
 3 #include <algorithm>
 4 using namespace std;
 5 
 6 char A[13][13] = {"Jia", "Yi", "Bing", "Ding", "Wu", "Ji", "Geng", "Xin", "Ren" ,"Gui"};
 7 char B[13][13] = {"zi", "chou", "yin", "mao", "chen", "si", "wu", "wei", "shen", "you", "xu","hai"};
 8 
 9 int main() {
10     int t, y;
11     scanf("%d", &t);
12     while (t--) {
13         scanf("%d", &y);
14         int d = y - 1911;
15         if (y < 0) d++;
16         while (d < 0) d += 60;
17         d %= 60;
18         int a = 7; int b = 11;
19         while (d) {
20             a = (a+1)%10;
21             b = (b+1)%12;
22             d--;
23         }
24         printf("%s%s\n", A[a], B[b]);
25     }
26     return 0;
27 }
View Code

 

ZOJ 3623 Battle Ships

 

真是日了狗了

标签:

原文地址:http://www.cnblogs.com/cheater/p/4593397.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!