hdu 1076 An Easy Task

//题目链接:https://acm.hdu.edu.cn/showproblem.php?pid=1076

 1 #include<iostream>
 2 using namespace std;
 3 
 4 bool check_leap_year(int year)
 5 {
 6     if(year%4==0&&year%100!=0||year%400==0)
 7         return true;
 8     else
 9         return false;
10 }
11 
12 
13 int main()
14 {
15     int year,num;
16     int n;
17     cin>>n;
18     while(n--)
19     {
20         cin>>year>>num;
21         if(check_leap_year(year))
22         {
23             if(num==1)
24             {
25                 cout<<year<<endl;
26                 continue;
27             }
28             int cnt=1;
29             while(year++)
30             {
31                 if(check_leap_year(year))
32                 {
33                     cnt++;
34                     if(cnt==num)
35                     {
36                         cout<<year<<endl;
37                         break;
38                     }
39                 }
40             }
41         }
42         else
43         {
44             int cnt=0;
45             while(year++)
46             {
47                 if(check_leap_year(year))
48                 {
49                     cnt++;
50                     if(cnt==num)
51                     {
52                         cout<<year<<endl;
53                         break;
54                     }
55                 }
56             }
57         }
58     }
59     return 0;
60 }

 

posted @ 2021-08-26 22:03  细妹  阅读(25)  评论(0)    收藏  举报