QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#739598 | #6819. Largest Unique Wins | AmiyaCast# | WA | 0ms | 3876kb | C++20 | 1.8kb | 2024-11-12 22:21:42 | 2024-11-12 22:21:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
int main()
{
int n, m;
cin >> n >> m;
if (n % 2 == 1) {
cout << fixed << setprecision(10);
if(n == 2) {
for(int i = 1; i <= m - 1; i ++) {
cout << 0.0 << " ";
}
cout << 1.0 << endl;
for(int i = 1; i <= m - 1; i ++) {
cout << 0.0 << " ";
}
cout << 1.0 << endl;
return 0;
}
int b = m, i;
for (i = 1; i <= n; i++)
{
for (int j = 1; j < b; j++) cout << 0.0 << ' ';
cout << 1.0 << ' ';
for (int j = b + 1; j <= m; j++) cout << 0.0 << ' ';
cout << '\n';
b--;
if (b == 0)
{
i++;
break;
}
}
b = 1;
for (; i <= n; i++)
{
for (int j = 1; j < b; j++) cout << 0.0 << ' ';
cout << 1.0 << ' ';
for (int j = b + 1; j <= m; j++) cout << 0.0 << ' ';
cout << '\n';
b++;
if (b > m) b = 1;
}
return 0;
}
double sum = 1;
vector<double> ans(m);
for (int i = 0; i < m - 1; i++) {
double l = 0, r = sum;
for (int t = 1; t < 73; t++) {
double mid = (l + r) / 2;
double res = n;
for (int i = 0; i < n - 2; i++) {
res *= (sum - mid);
}
res *= mid;
res -= (1.0 - mid);
if (res < 0) l = mid;
else r = mid;
}
ans[i] = l;
sum -= l;
}
ans[m - 1] = sum;
for (int i = 0; i < n; i++) {
for (int j = m - 1; j >= 0; j--) {
cout << fixed << setprecision(10) << ans[j] << ' ';
}
cout << '\n';
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3876kb
input:
2 2
output:
0.6666666667 0.3333333333 0.6666666667 0.3333333333
result:
wrong answer 1's strategy is not optimal, current = 0.0000000000, better (2) = 0.6666666667