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 |
dashuitiyige#include <iostream> #include <stdio.h> using namespace std; void quickSort(double s[], int l, int r) { if (l < r) { int i = l, j = r; double x = s[l]; while (i < j) { while(i < j && s[j] >= x) j--; if(i < j) s[i++] = s[j]; while(i < j && s[i] < x) i++; if(i < j) s[j--] = s[i]; } s[i] = x; quickSort(s, l, i - 1); quickSort(s, i + 1, r); } } int main() { while(1){ int frontNum, rearNum; cin >> frontNum; if(frontNum == 0) return 0; cin >> rearNum; int front[12], rear[12]; for(int i = 0; i < frontNum; i++){ cin >> front[i]; } for(int i = 0; i < rearNum; i++){ cin >> rear[i]; } double rat[111]; int cnt = 0; for(int i = 0; i < frontNum; i++){ for(int j = 0; j < rearNum; j++){ rat[cnt] = rear[j]*1.0/front[i]; cnt++; } } quickSort(rat, 0, cnt-1); double spread = 0; for(int i = 0; i < cnt-1; i++){ if(rat[i+1]-rat[i] < 1e-5) continue; double tS = rat[i+1]/rat[i]; if(tS > spread) spread = tS; } printf("%.2lf\n", spread); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator