| ||||||||||
| 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 | |||||||||
自我更新,增加考虑到在date之前就已经有个triple peak的状况In Reply To:C++编的....到底还有哪些数据陷阱没考虑到呢......||| Posted by:wy at 2004-11-09 20:05:35 #include "math.h"
#include "stdio.h"
void main()
{
int p[15],e[15],i[15],d[15],tp[15];
int j,k,lim;
j=0;
do
{
j++;
scanf("%d %d %d %d",&p[j],&e[j],&i[j],&d[j]);
while (p[j]-23>0) p[j]=p[j]-23;
while (e[j]-28>0) e[j]=e[j]-28;
while (i[j]-33>0) i[j]=i[j]-33;
} while (p[j]!=-1 && e[j]!=-1 && i[j]!=-1 && d[j]!=-1);
lim=j-1;
for (j=1;j<=lim;j++)
{
for (k=1;;k++)
{
if ((k-i[j])%33!=0)
continue;
else
{
if ((k-e[j])%28!=0)
continue;
else
{
if ((k-p[j])%23!=0)
continue;
else
{
tp[j]=k-d[j];
if (tp[j]<0)
tp[j]=tp[j]+21252;
break;
}
}
}
}
}
for (j=1;j<=lim;j++)
{
printf("Case %d: the next triple peak occurs in %d days.\n",j,tp[j]);
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator