题目
思路:
先计算总分数 \(sum\),\(c_i=\frac{100}{a_i}\) 为每道题的每个测试点分数。
-
如果总分数达到 \(Au\) 线,直接输出
Already Au.
。 -
否则计算到达 \(Au\) 线还需多少分 \(p\),遍历所有题,求出每道题的失分,如果失分大于等于 \(p\),则输出\(\lceil\frac{p}{c_i}\rceil\),即至少再多通过几个测试点。否则输出
NaN
。
Code:
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, t, a[10], b[10], c[10];
int sum = 0;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i] >> b[i];
c[i] = 100 / a[i];
sum += c[i] * b[i];
}
cin >> t;
if (sum >= t) {
cout << "Already Au." << endl;
} else {
double p = t - sum;
for (int i = 1; i <= n; i++) {
double l = 100 - c[i] * b[i];
if (l >= p) {
cout << ceil(p / c[i]) << endl;
} else {
cout << "NaN" << endl;
}
}
}
return 0;
}
标签:10,06,P9740,int,题解,sum,cin,Au,cout
From: https://www.cnblogs.com/sky-lisu/p/17806074.html