QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#164096 | #7046. Function! | wifi32767# | WA | 12ms | 9220kb | Python3 | 699b | 2023-09-04 19:46:30 | 2023-09-04 19:46:30 |
Judging History
answer
from math import sqrt
def safe_sqrt(x):
lk , rk = 0, 2 * int(sqrt(x))
while (lk < rk):
mid = (lk + rk) >> 1
if (mid * mid >= x):rk = mid
else:lk = mid + 1
return lk
mod = 998244353
def cal(x):
return (2 * x ** 3 + 3 * x * x + x) // 6
n = int(input())
ans = 0
k = safe_sqrt(n)
for i in range(2, k + 1):
t = i - 1
cnt = 1
while (t < n):
m = (t + 1) * i - 1
if (m > n):ans = (ans + i * cnt * (n - t) % mod) % mod
else:ans = (ans + i * cnt * (m - t) % mod) % mod
t = m
cnt += 1
ans = (ans + (n + 1) * (n + k + 1) % mod * (n - k) // 2) % mod
ans += mod + cal(k) - cal(n)
print(ans % mod)
详细
Test #1:
score: 100
Accepted
time: 9ms
memory: 9108kb
input:
2
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 9220kb
input:
10
output:
236
result:
ok 1 number(s): "236"
Test #3:
score: 0
Accepted
time: 7ms
memory: 9040kb
input:
20
output:
1646
result:
ok 1 number(s): "1646"
Test #4:
score: 0
Accepted
time: 12ms
memory: 9180kb
input:
27
output:
3862
result:
ok 1 number(s): "3862"
Test #5:
score: 0
Accepted
time: 10ms
memory: 9124kb
input:
37
output:
9571
result:
ok 1 number(s): "9571"
Test #6:
score: 0
Accepted
time: 9ms
memory: 9100kb
input:
100
output:
175028
result:
ok 1 number(s): "175028"
Test #7:
score: 0
Accepted
time: 11ms
memory: 9220kb
input:
123
output:
322744
result:
ok 1 number(s): "322744"
Test #8:
score: 0
Accepted
time: 7ms
memory: 9048kb
input:
2548
output:
765669726
result:
ok 1 number(s): "765669726"
Test #9:
score: 0
Accepted
time: 7ms
memory: 9044kb
input:
12448
output:
159637196
result:
ok 1 number(s): "159637196"
Test #10:
score: 0
Accepted
time: 10ms
memory: 9076kb
input:
65535
output:
120089112
result:
ok 1 number(s): "120089112"
Test #11:
score: 0
Accepted
time: 12ms
memory: 9076kb
input:
102458
output:
475774506
result:
ok 1 number(s): "475774506"
Test #12:
score: -100
Wrong Answer
time: 8ms
memory: 9112kb
input:
222333
output:
563459719
result:
wrong answer 1st numbers differ - expected: '64337543', found: '563459719'