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 |
大水题1A#include <iostream> #include <string> #include <cmath> #include <algorithm> using namespace std; struct team{ int sc[7]; string name; int solved; int total; int geo; void getData(){ solved = 0; total = 0; for(int i = 0; i < 7; i++){ total += sc[i]; if(sc[i] != 0) solved++; } if(solved == 0) geo = 0; else{ double sum = 0.0; for(int i = 0; i < 7; i++){ if(sc[i] != 0) sum += log(sc[i]+0.0); } sum /= solved; geo = (int)(0.5 + exp(sum)); } } }teams[32]; bool compare(const team &t1, const team &t2){ if(t1.solved > t2.solved) return true; if(t1.solved < t2.solved) return false; if(t1.total < t2.total) return true; if(t1.total > t2.total) return false; if(t1.geo < t2.geo) return true; if(t1.geo > t2.geo) return false; return t1.name < t2.name; } bool operator==(const team &t1, const team &t2){ return t1.solved == t2.solved && t1.total == t2.total && t1.geo == t2.geo; } int N; int cnt = 0; int ws(int n){ if(n < 10) return 1; if(n < 100) return 2; if(n < 1000) return 3; return 4; } void print(int wz, int mc){ if(mc < 10) cout << 0; cout << mc << " " << teams[wz].name; int len = teams[wz].name.length(); for(int i = 0; i < 11-len; i++) cout << " "; cout << teams[wz].solved; int WS = ws(teams[wz].total); for(int i = 0; i < 5-WS; i++) cout << " "; cout << teams[wz].total; WS = ws(teams[wz].geo); for(int i = 0; i < 4-WS; i++) cout << " "; cout << teams[wz].geo; for(int i = 0; i < 7; i++){ WS = ws(teams[wz].sc[i]); for(int j = 0; j < 4-WS; j++) cout << " "; cout << teams[wz].sc[i]; } cout << endl; } int main() { while(cin >> N){ cnt++; if(N == 0) break; for(int i = 0; i < N; i++){ cin >> teams[i].name; for(int j = 0; j < 7; j++){ cin >> teams[i].sc[j]; } teams[i].getData(); } sort(teams, teams+N, compare); cout << "CONTEST " << cnt << endl; int mc = 1; for(int i = 0; i < N; i++){ if(i == 0) mc = 1; else if(!(teams[i] == teams[i-1])){ mc = i+1; } print(i, mc); } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator