当前位置: 代码迷 >> 综合 >> ACM Plan UVa - 11242 Tour de France
  详细解决方案

ACM Plan UVa - 11242 Tour de France

热度:31   发布时间:2023-10-15 12:39:09.0

Talk is cheap. Show me the code. —— Linus Torvalds

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <set>
using namespace std;
int main()
{
    //freopen("i.txt", "r", stdin);int n, m, f[15], r[15];while(scanf("%d", &n), n){
    vector<double> v;set<double> ans;scanf("%d", &m);for(int i = 0; i < n; i++) scanf("%d", &f[i]);for(int i = 0; i < m; i++) scanf("%d", &r[i]);for(int i = 0; i < n; i++)for(int j = 0; j < m; j++)v.push_back(1.0 * f[i] / r[j]);sort(v.begin(), v.end());int limit = v.size();for(int i = 0; i < limit - 1; i++)ans.insert(-v[i + 1] / v[i]);printf("%.2lf\n", -*(ans.begin()));}return 0;
}