CodeForces

来源:互联网 发布:淘宝首页导航尺寸 编辑:程序博客网 时间:2024/06/16 20:53
点击打开链接
A. New Year and Days
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
Today is Wednesday, the third day of the week. What's more interesting is that tomorrow is the last day of the year 2015.

Limak is a little polar bear. He enjoyed this year a lot. Now, he is so eager to the coming year 2016.

Limak wants to prove how responsible a bear he is. He is going to regularly save candies for the entire year 2016! He considers various saving plans. He can save one candy either on some fixed day of the week or on some fixed day of the month.

Limak chose one particular plan. He isn't sure how many candies he will save in the 2016 with his plan. Please, calculate it and tell him.

Input
The only line of the input is in one of the following two formats:

"x of week" where x (1 ≤ x ≤ 7) denotes the day of the week. The 1-st day is Monday and the 7-th one is Sunday.
    "x of month" where x (1 ≤ x ≤ 31) denotes the day of the month.
Output
Print one integer — the number of candies Limak will save in the year 2016.
Examples
input:
4 of week
output:
52
input:
30 of month
output:
11
这道题就是要注意2016年是不是闰年的问题,只要这个明白,这题很水。
#include<cstdio>#include<cstring>int main(){char a[20],b[20];int k,i,n;while(scanf("%d %s %s",&n,a,b)!=EOF){if(!strcmp(b,"week")){if(n==5||n==6){printf("53\n");}else{printf("52\n");}}if(!strcmp(b,"month")){if(n==30){printf("11\n");}else if(n==31){printf("7\n");}else{printf("12\n");}}}return 0;}