Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

请高手帮我看看,哪个地方有问题啊,给定的数据输出都正确,可就是wa!江湖救急啊!谢谢大虾了!

Posted by peteryys at 2008-11-14 23:04:16 on Problem 1006
#include<iostream>
#define p_r 23 //定义P,e,r周期
#define e_r 28   
#define i_r 33
using namespace std;
int main()
{
 int p,e,i,d,total=1; //total控制输出里面的“第几个数据组”
 while(cin>>p>>e>>i>>d&&p!=-1&&e!=-1&&i!=-1&&d!=-1)  
 {int tp=p; 
 while(tp<21252)   //如果输入的p小于21252,进行循环判断
 {tp+=p_r; //
 if(tp<=d) continue; //如果得到的tp<=d,则继续增加tp
 else  //否则:若tp与e的起始日期之间的天数正好是e的周期整数倍且i也一样,则输出“这个日期-d”,从而得到答案,并break退出循环,进行下一组数据求解。
 {if((tp-e)%e_r==0&&(tp-i)%i_r==0) {cout<<"Case "<<total<<": the next triple peak occurs in "<<tp-d<<" days."<<endl;break;}}
 }
 total++; 
 }
 return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator