QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#94093 | #5477. Cake Decoration | whatever# | AC ✓ | 6439ms | 3548kb | C++17 | 2.3kb | 2023-04-05 12:19:40 | 2023-04-05 12:19:42 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a, I = b; i <= I; ++i)
#define per(i, a, b) for (int i = a, I = b; i >= I; --i)
using namespace std;
using i64 = long long;
const int P = 998244353;
i64 x, l, r;
int main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> x >> l >> r, --r;
i64 ans = 0;
auto calc = [&](i64 L, i64 R) {
L = max(l, L), R = min(r, R);
return max(0ll, R - L + 1);
};
auto check = [&](i64 x) {
return x >= l && x <= r;
};
for (i64 a = 1; a * (a + 1) * (a + 2) * (a + 3) <= x; ++a) {
for (i64 b = a + 1; a * b * (b + 1) * (b + 2) <= x; ++b) {
i64 lim = x / (a * b), L = b + 1, R = sqrt(lim);
while (R * (R + 1) > lim) --R;
ans += (R - L + 1) * check(a + b);
ans += calc(a + L, a + R) + calc(b + L, b + R);
rep(t, 0, 1) {
i64 tmp = (t == 0) ? r : (l - 1), res = 0;
{
i64 l = L, r = R, pos = R + 1;
while (l <= r) {
i64 mid = (l + r) >> 1;
if (a + lim / mid <= tmp) pos = mid, r = mid - 1;
else l = mid + 1;
}
res += R - pos + 1;
}
{
i64 l = L, r = R, pos = R + 1;
while (l <= r) {
i64 mid = (l + r) >> 1;
if (b + lim / mid <= tmp) pos = mid, r = mid - 1;
else l = mid + 1;
}
res += R - pos + 1;
}
{
i64 l = L, r = R, pos = R + 1;
while (l <= r) {
i64 mid = (l + r) >> 1;
if (mid + lim / mid <= tmp) pos = mid, r = mid - 1;
else l = mid + 1;
}
res += R - pos + 1;
}
ans += (t ? -res : res);
}
// for (i64 c = L; c <= R; ++c) {
// i64 d = lim / c;
// ans += check(a + d) + check(b + d) + check(c + d);
// }
}
}
cout << (ans * 4) % P << "\n";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
input:
24 4 6
output:
12
result:
ok single line: '12'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3372kb
input:
30 5 6
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3432kb
input:
30 9 20
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 6045ms
memory: 3292kb
input:
100000000000000 1 100000000000000
output:
288287412
result:
ok single line: '288287412'
Test #5:
score: 0
Accepted
time: 2ms
memory: 3340kb
input:
51256 4 35
output:
29116
result:
ok single line: '29116'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3436kb
input:
5845 10 163
output:
10724
result:
ok single line: '10724'
Test #7:
score: 0
Accepted
time: 2ms
memory: 3488kb
input:
47139 6 167
output:
71716
result:
ok single line: '71716'
Test #8:
score: 0
Accepted
time: 2ms
memory: 3548kb
input:
20603 5 167
output:
36556
result:
ok single line: '36556'
Test #9:
score: 0
Accepted
time: 2ms
memory: 3380kb
input:
37521 1 76
output:
46956
result:
ok single line: '46956'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3292kb
input:
1 1 10
output:
0
result:
ok single line: '0'
Test #11:
score: 0
Accepted
time: 5993ms
memory: 3380kb
input:
97083668416826 7 3808058212682
output:
392082021
result:
ok single line: '392082021'
Test #12:
score: 0
Accepted
time: 5432ms
memory: 3288kb
input:
81206220725808 2 45630676823009
output:
956896057
result:
ok single line: '956896057'
Test #13:
score: 0
Accepted
time: 5512ms
memory: 3352kb
input:
83357713762616 8 7064282922851
output:
238276229
result:
ok single line: '238276229'
Test #14:
score: 0
Accepted
time: 5575ms
memory: 3492kb
input:
85445471832361 6 56105073865950
output:
611528255
result:
ok single line: '611528255'
Test #15:
score: 0
Accepted
time: 5871ms
memory: 3436kb
input:
92699451513867 7 40224031632009
output:
527678799
result:
ok single line: '527678799'
Test #16:
score: 0
Accepted
time: 5779ms
memory: 3432kb
input:
91239680645595 2 6753821
output:
949101816
result:
ok single line: '949101816'
Test #17:
score: 0
Accepted
time: 5553ms
memory: 3348kb
input:
84407166448013 9 9804427
output:
100140616
result:
ok single line: '100140616'
Test #18:
score: 0
Accepted
time: 5843ms
memory: 3492kb
input:
92300784798569 1 7627255
output:
506797132
result:
ok single line: '506797132'
Test #19:
score: 0
Accepted
time: 5662ms
memory: 3440kb
input:
86360099055961 16 9430857
output:
909028853
result:
ok single line: '909028853'
Test #20:
score: 0
Accepted
time: 6011ms
memory: 3492kb
input:
96378494166704 16 4791452
output:
961637838
result:
ok single line: '961637838'
Test #21:
score: 0
Accepted
time: 6205ms
memory: 3432kb
input:
92800119725342 19 71735
output:
549693103
result:
ok single line: '549693103'
Test #22:
score: 0
Accepted
time: 6130ms
memory: 3424kb
input:
99241248175798 28 509556
output:
885647806
result:
ok single line: '885647806'
Test #23:
score: 0
Accepted
time: 5923ms
memory: 3436kb
input:
90117794770692 17 324480
output:
701148580
result:
ok single line: '701148580'
Test #24:
score: 0
Accepted
time: 6178ms
memory: 3372kb
input:
99417213318477 67 305057
output:
478902343
result:
ok single line: '478902343'
Test #25:
score: 0
Accepted
time: 5819ms
memory: 3368kb
input:
90584131165693 78 897660
output:
879735139
result:
ok single line: '879735139'
Test #26:
score: 0
Accepted
time: 6144ms
memory: 3372kb
input:
92129120236843 702 5645
output:
28323443
result:
ok single line: '28323443'
Test #27:
score: 0
Accepted
time: 6110ms
memory: 3340kb
input:
90203225783100 802 6272
output:
966952096
result:
ok single line: '966952096'
Test #28:
score: 0
Accepted
time: 5792ms
memory: 3420kb
input:
82248112022135 533 2266
output:
280479804
result:
ok single line: '280479804'
Test #29:
score: 0
Accepted
time: 6009ms
memory: 3376kb
input:
84853900427215 368 25431
output:
471070321
result:
ok single line: '471070321'
Test #30:
score: 0
Accepted
time: 6255ms
memory: 3376kb
input:
91754392379969 149 24312
output:
577285220
result:
ok single line: '577285220'
Test #31:
score: 0
Accepted
time: 6439ms
memory: 3444kb
input:
100000000000000 1 2
output:
0
result:
ok single line: '0'
Test #32:
score: 0
Accepted
time: 5711ms
memory: 3284kb
input:
100000000000000 10000000000000 100000000000000
output:
36
result:
ok single line: '36'