New Year and Days
来源:互联网 发布:北京海洋馆客流量数据 编辑:程序博客网 时间:2024/05/16 20:31
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.
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.
Print one integer — the number of candies Limak will save in the year 2016.
4 of week
52
30 of month
11
Polar bears use the Gregorian calendar. It is the most common calendar and you likely use it too. You can read about it on Wikipedia if you want to – https://en.wikipedia.org/wiki/Gregorian_calendar. The week starts with Monday.
In the first sample Limak wants to save one candy on each Thursday (the 4-th day of the week). There are 52 Thursdays in the 2016. Thus, he will save 52 candies in total.
In the second sample Limak wants to save one candy on the 30-th day of each month. There is the 30-th day in exactly 11 months in the 2016 — all months but February. It means that Limak will save 11 candies in total.
这个题目刚开始做的时候就是把所有的满足一年中完整一个星期的算出来,然后把剩下的几天都加上,用数组的方式把这些个数都存起来。
#include <cstdio>#include <cstring>int x[12]={31,29,31,30,31,30,31,31,30,31,30,31};int y[7]={52,52,52,52,53,53,52};int main(){ int number; while(scanf("%d",&number)!=EOF) { char name[20]; gets(name); if (name[4]=='w') { printf("%d\n",y[number-1]); } else { int sum=0; for (int number1=0;number1<12;number1++) { if (x[number1]/number>=1) { sum+=1; } } printf("%d\n",sum); } } return 0;}
- New Year and Days
- New Year and Days
- New Year and Days
- New Year and Days
- New Year and Days
- New Year and Days
- New Year and Days
- New Year and Days
- New Year and Days
- New Year and Days
- New Year and Days
- A. New Year and Days
- Codeforces New Year and Days
- 【codeforces】New Year and Days
- G - New Year and Days
- 【codeforces】New Year and Days
- CodeForces 611A New Year and Days
- 【CodeForces】[659A]New Year and Days
- 如何快速制作EDIUS中的黑场过渡
- UIBezierPath精讲
- 尽情享受美妙音乐----英国PURE公司Jongo S3无线音箱一周使用体验
- java 修改web-root folder 的值
- weChat开发
- New Year and Days
- Mongodb aggregate timezone 问题
- 错误:HttpServlet was not found on the Java
- Eclipse开发工具的使用
- 根据地址获取经度纬度
- MySQL数据库的安装
- NRT日志系统:flume+morphline+solr+hue配置
- 关于java的几个名词
- SQL中的cast和convert的用法和区别