New term and days

来源:互联网 发布:mysql with as 用法 编辑:程序博客网 时间:2024/05/17 06:57

New term and days

TimeLimit:2000MS  MemoryLimit:256MB
64-bit integer IO format:%I64d

Problem Description

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.

SampleInput 1
4 of week
SampleOutput 1
52
SampleInput 2
30 of month
SampleOutput 2

11



今天是星期三,一周中的第三天,明天就是2015年的最后一天。

Limak是一只小熊,它很期待2016年。

Limak靠吃糖维生,为了证明自己是有多么努力的活下去,他决定在2016年一整年中,定期的存一些糖。它考虑过很多种存糖方案,它可以在一周的某一天或者一个月的某一天存一颗糖。        

Limak决定从两种方案中选择一种,但是他不知道按照这种方式,他会在2016年一整年存多少糖。请你计算后告诉它。

#include<cstdio>  #include<algorithm>  #include<cstring>  using namespace std;  int main(){      int x;      char str1[10],str2[10];      while(scanf("%d %s %s",&x,str1,str2)==3){              if(strcmp(str2,"month")==0){                  if(x<=29){                      printf("12\n");                  }                  else if(x==30){                      printf("11\n");                  }                  else if(x==31){                      printf("7\n");                  }              }              else if(strcmp(str2,"week")==0){                  if(x==5||x==6){                      printf("53\n");                  }                  else{                      printf("52\n");                  }              }      }      return 0;  }  



0 0
原创粉丝点击