First Date |
Time Limit: 3000ms, Special Time Limit:7500ms, Memory Limit:65536KB |
Total submit users: 77, Accepted users: 46 |
Problem 12952 : No special judgement |
Problem description |
Given the last day for which the Julian calendar is in effect for some country (expressed as a Julian date), determine the next day’s Gregorian date, i.e., the first date that uses the Gregorian calendar. |
Input |
For each test case, the input consists of one line containing a date in the |
Output |
For each test case, print the first Gregorian date after the calendar |
Sample Input |
1582-10-04 |
Sample Output |
1582-10-15 |
题意:J日历闰年只要被4整除;G日历能被4整除但不能被100整除,或者能被400整除的是闰年;
先在已知J的日历日期,问你G的日历显示的日期?
表示自己不会算钱,这次连日子都算不好。。。。。。。。。。。。。悲剧!
这次就被黑在这里了。。。。。无语。
题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12952
AC代码:
#include<stdio.h> void Print(int h,int m,int s)
{
printf("%d",h); if(m>) printf("-%d",m);
else printf("-0%d",m);
if(s>) printf("-%d\n",s);
else printf("-0%d\n",s);
}
int main()
{
int i,j,d;
int sum;
int hh,mm,ss;
int year,mouth,day;
int s1[]= {,,,,,,,,,,,,};
int s2[]= {,,,,,,,,,,,,};
while(~scanf("%d-%d-%d",&hh,&mm,&ss))
{ int fa,fb,fc,fd;
// fa=hh/4;
fb=hh/;
fc=hh/;
fd=fb-fc-;
year=hh;
mouth=mm;
day=ss+fd;
// printf("%d\t%d\t%d\t%d\n",fa,fb,fc,fd);
sum=;
// printf("%d\n",day);
if(year%==&&year%!=&&mm<=)
day--;
for(i=mm; i<; i++)
{
// sum+=s1[i];
if(i==&&((year%==&&year%!=)||year%==))
{
if(day>)
{
day-=;
mouth++;
if(mouth>)
{
mouth=;
i=;
year++;
}
}
else
break;
} else if(day>s1[i])
{
day-=s1[i];
mouth++;
if(mouth>)
{
mouth=;
i=;
year++;
}
}
else
break; }
Print(year,mouth,day);
}
return ;
}
超时,和RE的代码。。。。呜呜,过不了
why?
#include<stdio.h>
#include<string.h> #define ll __int64 int leapj(ll y)
{
if(y%==)
return ;
else
return ;
}
int leapg(ll y)
{
if(((y%==)&&(y%!=))||(y%==))
return ;
else
return ;
} void Print(ll h,ll m,ll s)
{
printf("%I64d",h); if(m>) printf("-%I64d",m);
else printf("-0%I64d",m);
if(s>) printf("-%I64d\n",s);
else printf("-0%I64d\n",s);
}
int main()
{
ll i,j,d;
ll num;
ll hh,mm,ss;
ll HH,MM,SS;
ll s1[]= {,,,,,,,,,,,,};
ll s2[]= {,,,,,,,,,,,,};
ll s3[]= { ,, , , , , , , , ,,,};
while(~scanf("%I64d-%I64d-%I64d",&hh,&mm,&ss))
{
ll a=(hh-)/;
if(leapj(hh)&&(mm==||mm==)&&ss<)
a--; // printf("a %d\n",a); num=(hh-)*+a+;
if(hh>)
{
for(j=;j<mm; j++)
{
num+=s1[j];
}
// if(leapj(hh)&&(mm==2&&ss==29||mm>2))
// num++;
num+=ss;
}
// printf("num %I64d\n",num);
// printf("hh %d\n",hh);
if(hh==&&num<=)
{
for(j=; j<; j++)
{
if(num>s3[j])
{
num-=s3[j];
mm++;
}
else
break;
}
ss+=num;
Print(hh,mm,ss);
} else
{
// num-=365;
// printf("hh %d\n",hh);
HH=; while(num>=)
{
// printf("%I64d\t%d\n",num,hh);
num-=;
if(((HH%==)&&(HH%!=))||(HH%==))
num--;
HH++;
} MM=;
SS=;
// printf("%I64d %I64d\n",num,HH);
if(leapg(HH))
{
for(j=; j<; j++)
{
MM++;
if(num>s2[j])
{
num-=s2[j];
}
else
break;
}
SS=num;
}
else
{
for(j=; j<; j++)
{
MM++;
if(num>s1[j])
{
num-=s1[j];
}
else
break;
}
SS=num;
} Print(HH,MM,SS);
} }
return ;
}