水题 ZOJ 3876 May Day Holiday

题目传送门

 1 /*
 2     水题:已知1928年1月1日是星期日,若是闰年加1,总天数对7取余判断就好了;
 3 */
 4 #include <cstdio>
 5 #include <iostream>
 6 #include <algorithm>
 7 #include <cmath>
 8 #include <cstring>
 9 #include <string>
10 #include <map>
11 #include <set>
12 #include <queue>
13 #include <vector>
14 using namespace std;
15
16 const int MAXN = 1e4 + 10;
17 const int INF = 0x3f3f3f3f;
18 int cnt[MAXN];
19
20 void leap(void)
21 {
22     memset (cnt, 0, sizeof (cnt));
23
24     for (int i=1900; i<=10000; ++i)
25     {
26         if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0)
27             cnt[i] = 1;
28     }
29 }
30
31 int main(void)      //ZOJ 3876 May Day Holiday
32 {
33     //freopen ("H.in", "r", stdin);
34
35     int t;
36
37     leap ();
38     scanf ("%d", &t);
39     while (t--)
40     {
41         int year, day;
42         scanf ("%d", &year);
43
44         day = (year - 1928) * 365;
45         for (int i=1928; i<=year; ++i)
46             day += cnt[i];
47         day += (31 + 28 + 31 + 30);
48
49         int ans = day % 7;
50         if(ans == 2) printf("6\n");
51         else if(ans == 4|| ans == 5 || ans == 3 || ans == 6) printf("5\n");
52         else if(ans == 1) printf("9\n");
53         else if(ans == 0) printf("6\n");
54     }
55
56
57     return 0;
58 }
时间: 2025-01-03 12:44:10

水题 ZOJ 3876 May Day Holiday的相关文章

水题 ZOJ 3875 Lunch Time

题目传送门 1 /* 2 水题:找排序找中间的价格,若有两个,选价格大的: 3 写的是有点搓:) 4 */ 5 #include <cstdio> 6 #include <iostream> 7 #include <algorithm> 8 #include <cmath> 9 #include <cstring> 10 #include <string> 11 #include <map> 12 #include <

ZOJ 3876 May Day Holiday

As a university advocating self-learning and work-rest balance, Marjar University has so many days of rest, including holidays and weekends. Each weekend, which consists of Saturday and Sunday, is a rest time in the Marjar University. The May Day, al

ZOJ 3876 May Day Holiday 蔡勒公式

                                               H - May Day Holiday Description As a university advocating self-learning and work-rest balance, Marjar University has so many days of rest, including holidays and weekends. Each weekend, which consists o

ZOJ 3609 Modular Inverse (水题)

Modular Inverse Time Limit: 2 Seconds      Memory Limit: 65536 KB The modular modular multiplicative inverse of an integer a modulo m is an integer x such that a-1≡x (mod m). This is equivalent to ax≡1 (mod m). Input There are multiple test cases. Th

ZOJ 3708 Density of Power Network (水题)

Density of Power Network Time Limit: 2 Seconds      Memory Limit: 65536 KB The vast power system is the most complicated man-made system and the greatest engineering innovation in the 20th century. The following diagram shows a typical 14 bus power s

2015南阳CCPC L - Huatuo&#39;s Medicine 水题

L - Huatuo's Medicine Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Huatuo was a famous doctor. He use identical bottles to carry the medicine. There are different types of medicine. Huatuo put medicines into the bottles and chain these b

sdut 2841 Bit Problem (水题)

题目 贴这个题是因为看题解有更简单的方法, 我做的时候是直接算的, 也很简单. 贴一下题解吧: 如果一个整数不等于 0,那么该整数的二进制表示中至少有一位是 1. 这个题结果可以直接输出 x - (x&(x-1)); 因为x-1 之后二进制下,就是最右边的1变成了0, 最右边的1的 右边所有的0变成了1, 不影响最左边. 我的代码: 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4

sdut 2413:n a^o7 !(第三届山东省省赛原题,水题,字符串处理)

n a^o7 ! Time Limit: 1000MS Memory limit: 65536K 题目描述 All brave and intelligent fighters, next you will step into a distinctive battleground which is full of sweet and happiness. If you want to win the battle, you must do warm-up according to my inst

杭电(hdu)2053 Switch Game 水题

Switch Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 13113    Accepted Submission(s): 7970 Problem Description There are many lamps in a line. All of them are off at first. A series of o