QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#397281 | #691. One Root | iee | WA | 399ms | 3772kb | C++14 | 768b | 2024-04-23 21:16:22 | 2024-04-23 21:16:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
constexpr ld eps = 1e-10;
int main() {
int n, m;
cin >> n >> m, n--;
ll res = 0;
for (int p = -m; p <= m; p++) {
ld v = (ld) p / (n + 1);
if (n % 2 == 0) {
if (p <= 0) res += m * 2 + 1;
else {
ld x = exp(log(v) / n);
ld l = pow(v, ld(n + 1) / n) - p * x, r = -l;
l = ceil(l - eps), r = floor(r + eps);
l = max<ld>(l, -m), r = min<ld>(r, m);
res += (int) round(l + m) + (int) round(m - r);
}
} else {
ld x = (v >= 0 ? exp(log(v) / n) : -exp(log(-v) / n));
ld t = pow(x, n + 1);
if (fabs(t - round(t)) < eps && (ll) round(t) >= -m && (ll) round(t) <= m) res++;
}
}
cout << res << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3632kb
input:
2 4
output:
5
result:
ok 1 number(s): "5"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3696kb
input:
3 5
output:
96
result:
ok 1 number(s): "96"
Test #3:
score: 0
Accepted
time: 234ms
memory: 3772kb
input:
2 1000000
output:
2001
result:
ok 1 number(s): "2001"
Test #4:
score: 0
Accepted
time: 373ms
memory: 3700kb
input:
3 1000000
output:
2022680596351
result:
ok 1 number(s): "2022680596351"
Test #5:
score: 0
Accepted
time: 399ms
memory: 3724kb
input:
1245 1000000
output:
2995843859203
result:
ok 1 number(s): "2995843859203"
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3636kb
input:
4 1371
output:
13
result:
wrong answer 1st numbers differ - expected: '9', found: '13'