| ||||||||||
| 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 | |||||||||
找到的测试数据都对了,还是wrong answer?#include<stdio.h>
void Input(long int *p,long int *e ,long int *i, int *d)
{
scanf("%d%d%d%d",p,e,i,d);
}
long int run(long int p,long int e,long int i,int d)
{
long int ans,b;
p=p%23;
while(1)
{
while(1)
{
p=p+23;
if(((p-e)%28==0)&&((p-i)%33==0))
break;
}
ans=p-d;
if(ans>0)
return ans;
}
}
void Output(int j,long int ans[])
{
int i;
for(i=1;i<=j;i++)
{
printf("Case %d: the next triple peak occurs in %d days.\n",i,ans[i]);
}
}
int main()
{
long int p,e,i,j=0,d,ans[1000];
while(1)
{
Input(&p,&e,&i,&d);
if((p==-1)&&(e==-1)&&(i==-1)&&(d==-1))
break;
j++;
ans[j]=run(p,e,i,d);
}
Output(j,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