QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#347494#6740. Functionwtz2333TL 378ms4852kbC++171.2kb2024-03-09 14:02:052024-03-09 14:02:11

Judging History

你现在查看的是最新测评结果

  • [2024-03-09 14:02:11]
  • 评测
  • 测评结果:TL
  • 用时:378ms
  • 内存:4852kb
  • [2024-03-09 14:02:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mo = 998244353;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    map<int,ll> mp;
    auto calc = [&](auto self,int x) -> ll {
        if(x == 0)return 0;
        if(mp.find(x) != mp.end()) return mp[x];
        ll l = 2,r;ll ans = 1;
        while(l <= 20210926){
            ll t = x / l;
            if(t) r = x / (x / l);
            else r = 20210926;
            r = min(r,1ll * 20210926);
            ans += 1ll * (r - l + 1) * self(self,x / l) % mo;
            ans %= mo;
            l = r + 1;
        }
        return mp[x] = ans;
    };
    if(n > 1) {
        cout << calc(calc,n) << endl;

    }else {
        ll ans = 0;
        int cnt = 1;
        vector<int> f(n + 1,1);
        for(int i = n - 1;i >= 1;i --) {
            for(int j = 2 * i;j <= n;j += i) {
                f[i] += f[j];
                // cerr << f[j] << " ";
            }//cerr << endl;
        }
        cout << f[1] << endl;
    }
}


// n / 20210926 <= k


/// 1 2 3 4 5 6 7 8

// 14 5 2 2 1 1 1 1

// 13 4 1 1 0 0 0 0

// 12 3 0 0 0 0 0 0

// 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3832kb

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3784kb

input:

2

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

100

output:

949

result:

ok 1 number(s): "949"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

10

output:

19

result:

ok 1 number(s): "19"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

1000

output:

48614

result:

ok 1 number(s): "48614"

Test #6:

score: 0
Accepted
time: 1ms
memory: 3600kb

input:

10000

output:

2602393

result:

ok 1 number(s): "2602393"

Test #7:

score: 0
Accepted
time: 2ms
memory: 3640kb

input:

100000

output:

139804054

result:

ok 1 number(s): "139804054"

Test #8:

score: 0
Accepted
time: 9ms
memory: 3664kb

input:

1000000

output:

521718285

result:

ok 1 number(s): "521718285"

Test #9:

score: 0
Accepted
time: 57ms
memory: 4212kb

input:

10000000

output:

503104917

result:

ok 1 number(s): "503104917"

Test #10:

score: 0
Accepted
time: 378ms
memory: 4852kb

input:

100000000

output:

198815604

result:

ok 1 number(s): "198815604"

Test #11:

score: -100
Time Limit Exceeded

input:

1000000000

output:


result: