| ||||||||||
| 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...郁闷(((m-_-m#include<iostream.h>
#include<iomanip.h>
const int p_cycle=23,e_cycle=28,i_cycle=33;
struct data
{
int p,e,i,d;
data *next;
};
void main(void)
{
int input_p,input_e,input_i,input_d,data_num=0,i,m,i_temp,p_temp,e_temp,d_temp;
data *head,*pointer;
pointer=head=new data;
cin>>input_p>>input_e>>input_i>>input_d;
pointer->next=new data;
while(!(input_p==-1&&input_e==-1&&input_i==-1&&input_d==-1))
{
pointer->p=input_p;
pointer->e=input_e;
pointer->i=input_i;
pointer->d=input_d;
pointer->next=new data;
pointer=pointer->next;
data_num++;
cin>>input_p>>input_e>>input_i>>input_d;
}
for(i=0,pointer=head;i<data_num;i++)
{
i_temp=pointer->i;
p_temp=pointer->p;
e_temp=pointer->e;
d_temp=pointer->d;
p_temp=(i_temp-p_temp)%p_cycle;
p_temp=p_temp>0?p_cycle-p_temp:-p_temp;
e_temp=(i_temp-e_temp)%e_cycle;
e_temp=e_temp>0?e_cycle-e_temp:-e_temp;
for(m=1;!((i_cycle*m)%p_cycle==p_temp&&(i_cycle*m)%e_cycle==e_temp);m++);
cout<<"Case "<<i+1<<": the next triple peak occurs in "<<i_cycle*m+i_temp-d_temp<<" days."<<endl;
pointer=pointer->next;
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator