Codeforces Good Bye 2015 A. New Year and Days 水题

本文探讨了一只名叫Limak的小北极熊如何制定2016年的糖果储蓄计划,通过周或月固定日期的方式,计算他在新的一年里能节省多少糖果。通过输入特定的日期参数,读者可以了解如何计算一年中的特定天数,进而帮助Limak实现他的糖果储蓄目标。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A. New Year and Days

题目连接:

http://www.codeforces.com/contest/611/problem/A

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

4 of week

Sample Output

52

Hint

题意:

给你两种询问,1.问你2016年中周x有多少天,2.问你2016年中x号一共有多少天。

题解:

数日历。

代码

#include<bits/stdc++.h>
using namespace std;


int C(int year,int month,int day)
{
    if(month<3)
    {
        year-=1;
        month+=12;
    }
    int c=(int)(year/100),y=year - 100*c;
    int w=(int)(c/4)-2*c+y+int(y/4)+(26*(month+1)/10)+day-1;
    w = (w%7+7)%7;
    return w;
}

int mon[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
char s1[10],s2[10],s3[10];
int main()
{
    int x;
    scanf("%d%s%s",&x,s1,s3);
    if(s3[0]=='m')
    {
        int ans = 0;
        for(int i=1;i<=12;i++)
            if(mon[i]>=x)
                ans++;
        cout<<ans<<endl;
    }
    else
    {
        if(x==5||x==6)return puts("53");
        return puts("52");
    }
}

转载于:https://www.cnblogs.com/qscqesze/p/5091148.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值