标签:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long LL;
typedef pair<int, int> pii;
class FoxAndGCDLCM {
public:
long long get(long long G, long long L) {
if (L % G != 0) return -1;
LL t = L / G;
LL ans = 1000000000000000ll;
for (LL i = 1; i * i <= t; ++i) {
if (t % i == 0 && __gcd(i, t / i) == 1) ans = min(ans, G * (t / i + i));
}
return ans;
}
};
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long LL;
typedef pair<int, int> pii;
const int N = 55;
double w[N];
class FoxAndBusiness {
public:
double minimumCost(int K, int totalWork, vector <int> a, vector <int> p) {
int n = a.size();
double l = 0, r = 1e18, mid;
for (int i = 1; i <= 500; ++i) {
mid = (l + r) * 0.5;
for (int j = 0; j < n; ++j)
w[j] = mid * a[j] - (double)a[j] * p[j];
sort(&w[0], &w[n]);
reverse(&w[0], &w[n]);
double t = 0;
for (int j = 0; j < K; ++j) t += w[j];
if (t >= 3600.0 * K) r = mid;
else l = mid;
}
return mid * totalWork;
}
};
标签:
原文地址:http://blog.csdn.net/mlzmlz95/article/details/46458335