CF Good Bye 2015 A- New Year and Days(CF611A)
来源:互联网 发布:佟丽娅长相知乎 编辑:程序博客网 时间:2024/05/16 22:43
第一次写cf的题解,希望以这种方式激励自己多思考一下这些算法,记录自己的成长历程。。。
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.
题意:判断一下星期几或者每个月第几号在2016年有多少个。
分析:签到题,不过写了这题我才发现2016年是闰年
code:
#include<stdio.h>#include<stdlib.h>#include<iostream>#include<queue>#include<math.h>using namespace std;int main(){ int n; char a[10],b[10]; cin>>n>>b>>a; if(a[0]=='w') { if(n==5 || n==6) cout<<53<<endl; else cout<<52<<endl; } else if(a[0]=='m') { if(n<=29)cout<<12<<endl; else if(n==30) cout<<11<<endl; else if(n==31) cout<<7<<endl; } return 0;}
- CF Good Bye 2015 A- New Year and Days(CF611A)
- Codeforces Good Bye 2015 A. New Year and Days
- Codeforces Good Bye 2015 A. New Year and Days (水)
- CF Good Bye 2015 C- New Year and Domino(CF611C)
- Good Bye 2015-New Year and Days(看日历找规律)
- CF Good Bye 2015 C. New Year and Domino && D. New Year and Ancient Prophecy (DP)
- CF Good Bye 2015 B- New Year and Old Property(CF611B)
- CF Good Bye 2015 E. New Year and Three Musketeers(贪心+枚举)
- CF Good Bye 2015 F. New Year and Cleaning(思维)
- Codeforces Good Bye 2015 C. New Year and Domino (预处理)
- Good Bye 2015 C New Year and Domino(dp)
- Codeforces Good Bye 2015 E. New Year and Three Musketeers
- Good Bye 2015 D. New Year and Ancient Prophecy
- Good BYe 2015 D New Year and Ancient Prophecy
- 【Codeforces Good Bye 2015】D. New Year and Ancient Prophecy
- Good Bye 2015 D. New Year and Ancient Prophecy
- codeforces Good Bye 2015 C - New Year and Domino
- codeforces Good Bye 2015 D. New Year and Ancient Prophecy
- caffe windows 学习第一步:编译和安装(vs2012+win 64)
- caffe windows学习:第一个测试程序
- Android5.1 Telecomm层通话去电流程两路进程分析之四通话连接创建成功通知显示InCallUI
- Android NDK开发(三)C语言操作Java对象
- \b 的解释
- CF Good Bye 2015 A- New Year and Days(CF611A)
- python学习(二) List和Tuple类型
- 面向对象设计原则---合成复用原则
- Caffe学习系列(1):安装配置ubuntu14.04+cuda7.5+caffe+cudnn
- Caffe学习系列(2):数据层及参数
- 蓝桥杯 基础练习 2n皇后问题 (简单dfs暴力+优化剪枝)
- Fragment从入门到精通之Activity中响应Fragment中的事件③
- 2016继续奋进
- alloy团队基于canvas的图片处理插件AlloyImage