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,谢谢#include<iostream> #include<string> #include<iomanip> #include<ios> #include<vector> #include<algorithm> #define pi 3.1415926; using namespace std; int findtp(int pday , int eday , int iday , int date) { int inipday = pday; while(1) { pday += 23; if(eday < pday) eday += 28; if(iday < pday) iday += 33; if(pday == eday && pday == iday) break; } return pday - date; } int main() { int p , i , e , d , count = 0 , x; vector<int> peak; while(cin >> p && cin >> e && cin >> i && cin >> d) { if(p == -1 && e == -1 && i == -1 && d == -1) break; if(findtp(p ,e , i ,d) == 0) peak.push_back(21252); else if(findtp(p , e, i ,d) > 21252) peak.push_back(findtp(p , e , i , d) - 21252); else peak.push_back(findtp(p , e , i , d)); count++; } for(x = 0;x < count;x++) cout << "Case " << x + 1 << ": " << "the next triple peak occurs in " << peak[x] << " days." << endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator