QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#164076 | #7046. Function! | wifi32767# | WA | 1ms | 3724kb | C++20 | 1.4kb | 2023-09-04 19:30:43 | 2023-09-04 19:30:43 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAX = 1e3 + 10, mod = 998244353;
ll n, k;
ll ans = 0;
ll safe_sqrt(ll x){
ll lk = 0, rk = 2 * sqrt(x);
while (lk < rk){
ll mid = (lk + rk) >> 1;
if (mid * mid >= x) rk = mid;
else lk = mid + 1;
}
return lk;
}
ll cal(ll x){
return 1ll * (2 * x * x * x + 3 * x * x + x) / 6;
}
void solve(){
cin >> n;
k = safe_sqrt(n);
for (int i = 2; i <= k; ++ i){
ll t = i - 1;
int cnt = 1;
while (t < n){
ll 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 ++;
}
}
ans = (ans + (n + 1) * (n + k + 1) % mod * (n - k) / 2) % mod;
ans += mod + cal(k) - cal(n);
cout << ans % mod << endl;
}
void did(){
ans = 0;
for (int a = 2; a <= n; ++ a){
for (int b = a; b <= n; ++ b){
ans += a * (int)floor(log(b) / log(a));
//cerr << ans << ' ';
}
//cerr << endl;
}
cout << ans;
}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//cout << fixed << setprecision(20);
//while (cin >> n)
//int _;cin>>_;while(_--)
solve();
//did();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3568kb
input:
2
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
10
output:
236
result:
ok 1 number(s): "236"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
20
output:
1646
result:
ok 1 number(s): "1646"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
27
output:
3862
result:
ok 1 number(s): "3862"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
37
output:
9571
result:
ok 1 number(s): "9571"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3636kb
input:
100
output:
175028
result:
ok 1 number(s): "175028"
Test #7:
score: 0
Accepted
time: 1ms
memory: 3724kb
input:
123
output:
322744
result:
ok 1 number(s): "322744"
Test #8:
score: -100
Wrong Answer
time: 1ms
memory: 3648kb
input:
2548
output:
-232574627
result:
wrong answer 1st numbers differ - expected: '765669726', found: '-232574627'