您的位置:首页 > 其它

hdu 1076 An Easy Task (水题)

2014-04-07 14:12 363 查看
思路:从第一个闰年开始,年份一直加4的算,算到第n个闰年。输出年份即可。

代码:

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

#define mst(a,b) memset(a,b,sizeof(a))
#define eps 10e-8

const int MAX_ = 10010;
const int MAX = 0x7fffffff;

int T, n, y, cnt;

bool isleap(int year){
return ((year%4==0&&year%100!=0)||(year%400==0));
}

int main(){
scanf("%d",&T);
while(T--){
scanf("%d%d",&y,&n);

while(!isleap(y)){
y++;
}
cnt = 1;
while(cnt != n){
y+=4;
if(isleap(y))cnt++;
}
cout<<y<<endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: