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 |
高手帮个忙帮忙检查下程序,样例都通过了 #include <iostream> #include <vector> #include <map> using namespace std; int main() { int count; int i, num,max; int sum; typedef map< int, int, less<int> > mid; mid pairs; vector<int> vc; while( (cin >> count) && (count != 0) ) { sum = 0; cin >> num; max = num; sum += num; for (i=1; i<count; i++) { cin >> num; if(num > max) { max = num; } sum += num; } for (i=1; i<=(sum/max); i++) { if(sum % i == 0) { pairs.insert(mid::value_type(sum/i,i)); } } mid::const_iterator iter = pairs.begin(); vc.push_back(iter->first); } for (i=0; i<vc.size(); i++) { cout << vc[i] << 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