首页 > 其他 > 详细

Good Bye 2015 A

时间:2016-01-29 00:21:05      阅读:168      评论:0      收藏:0      [点我收藏+]

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[n]);  
    else if(l==5){  
        if(n<=29)  
            printf("12\n");  
            if(n==30)  
            printf("11\n");  
            if(n==31)  
            printf("7\n");  
            }  
    return 0;  
}  

 

Good Bye 2015 A

原文:http://www.cnblogs.com/zhien-aa/p/5167641.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!