QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#178098 | #5377. $N$ 门问题 | zhoukangyang# | 0 | 1ms | 8056kb | C++11 | 1.9kb | 2023-09-13 17:57:58 | 2024-07-04 01:56:29 |
answer
#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); i++)
#define R(i, j, k) for(int i = (j); i >= (k); i--)
#define ll long long
#define ull unsigned long long
#define sz(a) ((int) a.size())
#define vi vector<int>
#define me(a, x) memset(a, x, sizeof(a))
using namespace std;
const int N = 1 << 21, L = 5e5, mod = 998244353;
double f[N];
ll n;
int k;
ll a[N], b[N];
ll rd() {
cin >> k;
L(i, 1, k) {
cin >> a[i] >> b[i];
}
n = 0;
while(true) {
int win = 1;
L(i, 1, k) {
if(n % b[i] != a[i]) {
win = 0;
break;
}
}
if(win) break;
++n;
if(n > 200) {
n = -1;
break;
}
}
return n;
}
map < vector < double >, double > MP[10];
double slv(vector < double > a, int cur) {
if(sz(a) == 2) {
return cur == 0;
}
if(cur > 1)
swap(a[1], a[cur]), cur = 1;
sort(a.begin() + 2, a.end());
if(MP[cur].count(a)) return MP[cur][a];
double win = 1;
L(p, 1, sz(a) - 1) if(p != cur) {
double sum1 = 0, sum2 = 0;
L(i, 0, sz(a) - 1) if(i != cur) {
sum1 += a[i];
if(i != p) sum2 += a[i];
}
sum1 /= sum2;
vector < double > b;
L(i, 0, sz(a) - 1) {
if(i == cur) b.emplace_back(a[i]);
else if(i != p) b.emplace_back(a[i] * sum1);
}
double mx = 0;
L(i, 0, sz(b) - 1) {
mx = max(mx, b[i]);
}
int total = 0;
double sum = 0;
L(i, 0, sz(b) - 1) {
if(fabs(b[i] - mx) <= 1e-9) {
total += 1;
sum += slv(b, i);
}
}
sum /= total;
win = min(win, sum);
}
return MP[cur][a] = win;
}
int main () {
ios :: sync_with_stdio(false);
cin.tie (0); cout.tie (0);
n = rd();
if(n < 2) {
cout << "error\n";
return 0;
}
vector < double > f(n);
L(i, 0, n - 1) {
f[i] = 1;
}
double ans = n > 13 ? (slv(f, 0) + slv(f, 1) * (n - 1)) / n : 0;
cout.precision(6); cout << fixed;
cout << ans << '\n';
return 0;
}
/*
(n-1)/(n-2) 1 [(n-1)/(n-2)] (n-1)/(n-2) (n-1)/(n-2) x
*/
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 8044kb
input:
1 2 3
output:
0.000000
result:
wrong answer 1st lines differ - expected: '0.500000', found: '0.000000'
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 10
Accepted
time: 1ms
memory: 7632kb
input:
8 1 160005726539569 1 233 0 1 1 2947295521 1 686719856393 1 54289 1 12649337 1 37281334283719577
output:
error
result:
ok single line: 'error'
Test #7:
score: -10
Wrong Answer
time: 1ms
memory: 8056kb
input:
10 2 64 0 2 2 512 2 4 2 32 2 16 2 256 0 1 2 8 2 128
output:
0.000000
result:
wrong answer 1st lines differ - expected: '0.500000', found: '0.000000'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%
Subtask #6:
score: 0
Wrong Answer
Test #57:
score: 0
Wrong Answer
time: 1ms
memory: 7696kb
input:
15 15 17 2 3 5 31 4 5 12 29 38 41 3 11 44 47 16 23 11 19 6 13 3 37 1 2 21 43 5 7
output:
error
result:
wrong answer 1st lines differ - expected: '0.000000', found: 'error'
Subtask #7:
score: 0
Skipped
Dependency #1:
0%