NYOJ - 1363 - 计划日(n天后的日期和星期)

博客提供了NYOJ的题目链接,链接为http://nyoj.top/problem/1363 ,可通过该链接访问相关题目。

题目链接:http://nyoj.top/problem/1363

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
const int inf = 0x3f3f3f3f;
const int N = 3e5+7;
int date[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{
    IOS; int t; cin >> t;
    while(t--)
    {
        string str; cin >> str;
        int n, k; cin >> k >> n;
        int year = atoi(str.substr(0, 4).c_str());
        int month = atoi(str.substr(4, 2).c_str());
        int day = atoi(str.substr(6, 2).c_str());
        int week = (n - 7 + k) % 7;
        while(n--)
        {
            if(year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
                date[2] = 29;
            else date[2] = 28;
            day++;
            if(day > date[month])
                day = 1, month++;
            if(month > 12)
            year++, month = 1;
        }
        printf("%d%02d%02d %d\n",year,month,day,week);
    }

}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值