1001 discount
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16int main() {
int test; cin >> test;
for (int i = 0; i < test; i++) {
double ret = 0.0;
int n; cin >> n;
for (int j = 0; j < n; ++j) {
double b; cin >> b;
double c; cin >> c;
double res = (1 - c) / (b + (1 - c));
if (res > ret)
ret = res;
}
printf("%.5lf\n", ret);
}
return 0;
}
1002 game
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long n, m;
cin >> n >> m;
if (n < 2) {
cout << 0 << endl;
continue;
}
long long pair = n / 2;
if (m < pair) {
cout << m * (2 * n - 2 * m - 1) << endl;
}
else {
cout << n * (n - 1) / 2 << endl;
}
}
return 0;
}
1003 permutation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
double p;
cin >> p;
if (p > 1)
cout << "No" << endl;
else
cout << "Yes" << endl;
}
return 0;
}