poj 1006
中国剩余定理
[cpp]
#include<iostream>
using namespace std;
int main()
{
int ncase = 0;
int p,e,i,d;
while (true) {
ncase++;
cin>>p>>e>>i>>d;
if (p == -1)
return 0;
int ans = (5544 * p + 14421 * e + 1288 * i-d+21252) % 21252;
if(ans==0)
ans=21252;
cout<<"Case "<<ncase<<": the next triple peak occurs in "<<ans<<" days."<<endl;
}
return 0;
}
[java]
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int ncase = 0;
while (true) {
ncase++;
int p = in.nextInt();
int e = in.nextInt();
int i = in.nextInt();
int d = in.nextInt();
if (p == -1)
return;
int ans = (5544 * p + 14421 * e + 1288 * i-d+21252) % 21252;
if(ans==0)
ans=21252;
System.out.println("Case " + ncase + ": the next triple peak occurs in " + ans + " days.");
}
}
}
摘自 Dreamer Thinker Doer
补充:软件开发 , Java ,