Use the plural form ``days‘‘ even if the answer is 1.
附上AC代码:
#include <iostream> #include <cstdio> #include <iomanip> #include <string> #include <cstring> #include <cmath> #include <algorithm> using namespace std; const double PI = acos(-1.0); const int loop1 = 23; const int loop2 = 28; const int loop3 = 33; int main() { ios::sync_with_stdio(false); int p, e, i, d; int cas = 1; while (cin >> p >> e >> i >> d) { if (p==-1 && e==-1 && i==-1 && d==-1) break; int day = 1; while (day) { if ((day-p)%loop1==0 && (day-e)%loop2==0 && (day-i)%loop3==0 && day>d) break; day++; } day -= d; cout << "Case " << cas << ": the next triple peak occurs in " << day << " days.\n"; cas++; } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/silenceneo/article/details/47748159