New Year and Days
2016-07-21 21:22
288 查看
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<cstring>
int main()
{
int d,n,t=0,i,j=0;
char a[20],b[20],c[20];
while (~scanf("%s%s%s",a,b,c))
{
n=strlen(c);
i=a[0]-'0';
if(n>4)
{
if(a[1]>='0'&&a[1]<='9')
{
j=a[1]-'0';
t++;
}
if(t!=0)
i=10*i+j;
if(i<=29)
printf("12\n");
else if(i==30)
printf("11\n");
else printf("7\n");
}
else
{
if(i<=4||i==7)
printf("52\n");
else
printf("53\n");
}
}
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 <cstdio> int month[] = {0,31,29,31,30,31,30,31,31,30,31,30,31}; int ant; char t[5]; char op[10]; int main() { int ans; while (~scanf ("%d %s %s",&ant,t,op)) { ans = 0; if (op[0] == 'm') { for (int i = 1 ; i <= 12 ; i++) if (month[i] >= ant) ans++; printf ("%d\n",ans); } else { ans = 366 / 7; if (ant == 5 || ant == 6) ans++; printf ("%d\n",ans); } } return 0; }#include<cstdio>
#include<cstring>
int main()
{
int d,n,t=0,i,j=0;
char a[20],b[20],c[20];
while (~scanf("%s%s%s",a,b,c))
{
n=strlen(c);
i=a[0]-'0';
if(n>4)
{
if(a[1]>='0'&&a[1]<='9')
{
j=a[1]-'0';
t++;
}
if(t!=0)
i=10*i+j;
if(i<=29)
printf("12\n");
else if(i==30)
printf("11\n");
else printf("7\n");
}
else
{
if(i<=4||i==7)
printf("52\n");
else
printf("53\n");
}
}
return 0;
}
相关文章推荐
- Android 数据存储详解(SharedPreferences, 文件, Sqlite, ContentProvider)
- while语句中i--与++i问题的讨论
- C#执行CMD命令
- Gnuradio 学习
- PAT-B 1010. 一元多项式求导
- 【POJ 3268】Silver Cow Party(邻接矩阵+优先队列优化+dij)
- HDU-1166 敌兵布阵(线段树模板题)
- UVA - 575 Skew Binary
- Android第三十九天
- 【慕课学习】《JavaScript深入浅出》——javascript数据类型
- org.w3c.dom中节点添加属性,没有一定的顺序,但是dom4j中添加的属性是有顺序的
- 训练之DP-数塔
- Kefa and Company
- Bulbs
- 杂记:Atmel sama5d3 Bus Matrix (MATRIX)
- 杂记:Atmel sama5d3 Bus Matrix (MATRIX)
- PAT-B 1009. 说反话
- 杂记:Atmel sama5d3 Bus Matrix (MATRIX)
- 杂记:Atmel sama5d3 Bus Matrix (MATRIX)
- 杂记:Atmel sama5d3 Bus Matrix (MATRIX)