| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
WA了十几次了,受不了了,哪里错了?In Reply To:输出好象多了一个空格 Posted by:yiyiyi4321 at 2005-07-28 14:41:44 #include <stdio.h>
inline int abs(const int &a)
{ return a>0?a:-a; }
int a,p,e,i,d,ans;
int main()
{
int ncase=1;
while(scanf("%d%d%d%d",&p,&e,&i,&d) && !(p==-1&&e==-1&&i==-1&&d==-1))
{
if(p==e && p==i)
{
ans = 21252 + e - d;
if(e>d)
ans = e-d;
printf("Case %d: the next triple peak occurs in %d days.\n",ncase++,ans);
continue;
}
for(a=(d-p)/23-1; a<=924; a++)
if((23*a+p>d && abs(23*a+p-e)%28==0 && abs(23*a+p-i)%33==0))
break;
ans = 23 * a + p - d;
if(ans>21252)
ans -= 21252;
if(ans<=0)
ans += 21252;
printf("Case %d: the next triple peak occurs in %d days.\n",ncase++,ans);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator