POJ 1006 Biorhythms 生理周期 水题
POJ 1006 Biorhythms,同百炼2977 生理周期
注意边界条件
#include <iostream> using namespace std; int mod (int a, int b) { if (a >= 0) return a%b; else return (b-(-a)%b)%b; } int main(void) { int a, b, c, t; int r; for (int i = 1; ; i++) { cin >> a >> b >> c >> t; if (a < 0) break; for (r = t + 33 - mod(t-c,33);;r+=33) { if (mod(r-a,23)) continue; if (mod(r-b,28)) continue; break; } cout << "Case "<< i << ": the next triple peak occurs in " << r-t << " days." <<endl; } return 0; }