游客 Signup | Login
中文 | En

2151 - 一千年以后

因为在 一千年以后   

世界早已没有我   
无法深情挽着你的手   
浅吻着你额头   
别等到 一千年以后   
所有人都遗忘了我   
那时红色黄昏的沙漠   
能有谁 解开缠绕千年的寂寞   

                                ——林俊杰《一千年以后》

一千年以后,谁也不知道世界将变成什么样子,但我们的思想将永存。给出一千年以后的某一天,你能输出这个日期是该年的第几天,也便不枉此生。

Input

 本题为n组输入样例,输入n组数据。

  一行为一组,包含三个数字:年(题目保证2000<=year<=5000)、月、日。题目保证月、日的输入也是合法的。

Output

对每个样例,在单独的一行中输出它是该年的第几天。

Examples

Input

2
3013 11 30
3007 8 15

Output

334
227

Solution C

#include <stdio.h>
int main()
{
  int n;
  scanf("%d",&n);
  int a1[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
   int a2[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
  while(n--)
  {int year,month,day;
   scanf("%d%d%d",&year,&month,&day);
   int sum=0;
   int i;
   if((year%4==0 && year%100!=0) || year%400==0)
   {for(i=1;i<=month-1;i++)
    sum=sum+a1[i];
    sum=sum+day;
    printf("%d\n",sum);
   }
   else
     {for(i=1;i<=month-1;i++)
    sum=sum+a2[i];
    sum=sum+day;
    printf("%d\n",sum);
   }
  }
  return 0;
}

Solution C++

#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <fstream>
using namespace std;

int luna[13]= {0,31,29,31,30,31,30,31,31,30,31,30,31};
int un_luna[13]= {0,31,28,31,30,31,30,31,31,30,31,30,31};

bool is_luna(int year)
{
    if((year%4==0 && year%100!=0)||(year%400==0))
        return 1;
    else
        return 0;
}

int main()
{
    int year,month,day;
//    ifstream cin;
//    ofstream cout;
//    cin.open("2.in");
//    cout.open("2.out");
    int t;
    scanf("%d",&t);
    while(t--)
    {
        cin>>year>>month>>day;
    int total=0;
    if(is_luna(year))
    {
        for(int i=1; i<month; i++)
        {
            total+=luna[i];
        }
        total+=day;
    }
    else
    {
        for(int i=1; i<month; i++)
        {
            total+=un_luna[i];
        }
        total+=day;
    }
    cout<<total<<endl;
}
return 0;
}

Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题