poj 1006 Biorhythms

<textarea cols="89" rows="17" name="code" class="cpp">//POJ 1006 Biorhythms (中国剩余定理) #include &lt;cstdio&gt; int mo(int a,int b,int c) { a*=b; int d=a; while (a%c!=1) a+=d; return a; } int main() { int a,b,c; int d; int count=0; while (scanf("%d%d%d%d",&amp;a,&amp;b,&amp;c,&amp;d) ) { if (a==-1 &amp;&amp; b==-1 &amp;&amp; c==-1 &amp;&amp; d==-1) break; int ans=(mo(23,28,33)*c+mo(23,33,28)*b+mo(28,33,23)*a-d+21252) % 21252; if (!ans) ans=21252; printf("Case %d: the next triple peak occurs in %d days./n",++count,ans); } return 0; } </textarea>

你可能感兴趣的:(poj 1006 Biorhythms)