hdu 1076 An Easy Task

简介:

    好久都没写题了,完全不会,这么简单的题WA了近10次,最后发现是思路不完全。

   最近要抓紧训练了,不然就坐等被虐了,明天开始学习dp


/*
author:jxy
lang:C/C++
university:China,Xidian University
**If you need to reprint,please indicate the source**
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#define INF 1E9
using namespace std;
bool isleap(int a)
{
    return a%4==0 && (a%100!=0||a%400==0);
}
int main()
{
    int T;
    scanf("%d",&T);
    int now,n;
    while(T--)
    {
        scanf("%d%d",&now,&n);
        if(!isleap(now))
        {
            now=(((now/4)+1)*4);
            if(!isleap(now))now+=4;
        }
        n--;
        while(n>=97)
        {
            n-=97;now+=400;
        }
        while(n>24)
        {
            int t=now/100;
            n-=24;now+=100;
            if(now/100>t&&(now/100)%4==0)n--;
        }
        int t=now%100;
        now+=n*4;
        if(n&&t>=now%100&&(now/100)%4!=0)now+=4;
        printf("%d\n",now);
    }
}


目录
相关文章
|
5月前
|
机器人
hdu1035 Robot Motion(简单模拟题)
hdu1035 Robot Motion(简单模拟题)
19 0
|
11月前
|
存储 测试技术 C++
C++/PTA Easy chemistry
In this question, you need to write a simple program to determine if the given chemical equation is balanced. Balanced means that the amount of elements on both sides of the “=” sign is the same.
80 0
Codeforces1486 C1.Guessing the Greatest (easy version)(交互题+二分)
Codeforces1486 C1.Guessing the Greatest (easy version)(交互题+二分)
73 0
|
机器人
HDU-1035,Robot Motion(DFS)
HDU-1035,Robot Motion(DFS)
Leetcode-Easy 72. Edit Distance
Leetcode-Easy 72. Edit Distance
66 0
Leetcode-Easy 72. Edit Distance
Leetcode-Easy 437. Path Sum III
Leetcode-Easy 437. Path Sum III
73 0
Leetcode-Easy 437. Path Sum III
HDOJ 1076 An Easy Task(闰年计算)
HDOJ 1076 An Easy Task(闰年计算)
74 0
|
Java 机器学习/深度学习

热门文章

最新文章