您的位置:首页 > 编程语言 > Go语言

Good Bye 2015 A

2016-01-05 17:02 302 查看
Problem A:http://codeforces.com/problemset/problem/611/A
A. New Year and Days
题意:某人要在2016年收集糖果,有两种不同的收集方式,按week或month。x表示week的周x或月的x号,只有到每周或每月的x时才会收集一颗糖果,问:在给定的月或周条件内,2016年能收集多少颗糖果。
思路:我是用数组存好,其实也可以更简洁,周的话除了5,6,7是53个,其他都是52个;月的话1-29都是12(闰年),30是11,31是7;
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main(){
int a[10]={0,52,52,52,52,53,53,52};
int n,l;
string s1,s2;
cin>>n>>s1>>s2;
l=s2.length() ;
if(l==4)
printf("%d\n",a
);
else if(l==5){
if(n<=29)
printf("12\n");
if(n==30)
printf("11\n");
if(n==31)
printf("7\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ACM 博客