New Year and Days
2016-07-21 20:19
399 查看
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.
Sample Input
Input
Output
Input
Output
#include<stdio.h>
#include<string.h>
int main()
{
char d[32];
int a,c,k;
while(~scanf("%d of %s",&a,d))
{
if(d[0]!='w')
{
if(a>=1&&a<=29)
k=12;
else if(a==30)
k=11;
else k=7;
}
else
{
if(a==5||a==6)
k=53;
else k=52;
}
printf("%d\n",k);
}
return 0;
}
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.
Sample Input
Input
4 of week
Output
52
Input
30 of month
Output
11
#include<stdio.h>
#include<string.h>
int main()
{
char d[32];
int a,c,k;
while(~scanf("%d of %s",&a,d))
{
if(d[0]!='w')
{
if(a>=1&&a<=29)
k=12;
else if(a==30)
k=11;
else k=7;
}
else
{
if(a==5||a==6)
k=53;
else k=52;
}
printf("%d\n",k);
}
return 0;
}
相关文章推荐
- BSOJ 4208 -- 【USACO 2013 Jan】奶牛队列
- 关于ajax的一些总结
- android开发环境安装
- 71. Simplify Path
- 关于消息队列的使用
- <context annotation-config />标签意义
- UVA - 591 Box of Bricks
- CodeForces597BRestaurant(sort+贪心)
- Codeforces 83B Doctor
- spring、spring mvc以及IOC的阅读
- 函数输出100全部素数(while 与 if 区别)
- 10分钟掌握XML、JSON及其解析
- HDU 1232 畅通工程 并查集
- 详解iOS中的数据存储
- The Python Tutorial - Input and Output
- CodeForces 454B Little Pony and Sort by Shift
- 【CodeForces】604A - Uncowed Forces(水)
- HDU 4267-Phage War-线段树
- myeclipse search查找打开第二个文件时第一个文件被关闭关闭
- MongoDB从不懂到装懂其三(Java操作MongoDB)