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);
    }
}


目录
相关文章
Leetcode-Easy 437. Path Sum III
Leetcode-Easy 437. Path Sum III
77 0
Leetcode-Easy 437. Path Sum III
|
机器学习/深度学习
Leetcode-Easy 136. Single Number
Leetcode-Easy 136. Single Number
100 0
Leetcode-Easy 136. Single Number
Leetcode-Easy 72. Edit Distance
Leetcode-Easy 72. Edit Distance
71 0
Leetcode-Easy 72. Edit Distance
Leetcode-Easy 728. Self Dividing Numbers
Leetcode-Easy 728. Self Dividing Numbers
80 0
Leetcode-Easy 728. Self Dividing Numbers
HDOJ 1076 An Easy Task(闰年计算)
HDOJ 1076 An Easy Task(闰年计算)
79 0
|
Java 文件存储
HDOJ(HDU) 2123 An easy problem(简单题...)
HDOJ(HDU) 2123 An easy problem(简单题...)
119 0
|
Java 文件存储
HDOJ(HDU) 2132 An easy problem
HDOJ(HDU) 2132 An easy problem
81 0
|
Java 机器学习/深度学习