| ||||||||||
| 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 | |||||||||
大水题竟然搞了一次RE。。。注意计算过程中如果已经超了1000000,之后的数还要继续读入。。。#include <iostream>
using namespace std;
int GCD(int a, int b){
if(!a) return b;
if(!b) return a;
if(a<b) return GCD(a, b%a);
return GCD(b, a%b);
}
int LCM(int a, int b){
return a/GCD(a,b)*b;
}
int main() {
while(1){
int n;
cin >> n;
if(!n) break;
int num = 1;
bool ky = true;
for(int i = 0; i < n; i++){
int tmp;
cin >> tmp;
if(ky) num = LCM(num,tmp);
if(num>=1000000) ky = false;//如果这里直接break就是RE
}
//cout << num << endl;
if(!ky) cout << "Too much money to pay!" << endl;
else cout << "The CEO must bring " << num << " pounds." << 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