QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#138166#6740. FunctionNicolas125841WA 43ms3772kbC++171.1kb2023-08-11 03:04:212023-08-11 03:04:22

Judging History

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

  • [2023-08-11 03:04:22]
  • 评测
  • 测评结果:WA
  • 用时:43ms
  • 内存:3772kb
  • [2023-08-11 03:04:21]
  • 提交

answer

#include <bits/extc++.h>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define depref(x, y) (x[y] - x[y-1])

unordered_map<ll, ll> s_f;

const ll mod = 998244353;
const ll CAP = 20210926;
const ll DPC = 100000;

vector<ll> dp(DPC + 1, 0);

void prep(){
    dp[0] = 0;
    dp[1] = 1;

    for(int i = 2; i <= DPC; i++){
        for(int j = 1; j * j <= i; j++){
            if(i % j)
                continue;

            dp[i] += dp[i / j];

            if(j * j != i)
                dp[i] += dp[j];

            dp[i] %= mod;
        }
    }

    for(int i = 1; i <= DPC; i++)
        dp[i] = (dp[i] + dp[i - 1]) % mod;
}

ll solve(ll n){
    if(n <= DPC)
        return dp[n];
    
    if(s_f.find(n) != s_f.end())
        return s_f[n];
    
    ll ans = 0;
    for(ll i = 2, ub; i <= min(n, CAP); i = ub + 1){
        ub = n / (n / i);
        
        ans += solve(n/i) * (min(CAP, ub) - i + 1) % mod;
        ans %= mod;
    }

    return s_f[n] = ans;
}

int main(){
    ll n;
    cin >> n;

    prep();

    cout << solve(n) << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 42ms
memory: 3684kb

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 43ms
memory: 3656kb

input:

2

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: 0
Accepted
time: 42ms
memory: 3708kb

input:

100

output:

949

result:

ok 1 number(s): "949"

Test #4:

score: 0
Accepted
time: 38ms
memory: 3712kb

input:

10

output:

19

result:

ok 1 number(s): "19"

Test #5:

score: 0
Accepted
time: 42ms
memory: 3700kb

input:

1000

output:

48614

result:

ok 1 number(s): "48614"

Test #6:

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

input:

10000

output:

2602393

result:

ok 1 number(s): "2602393"

Test #7:

score: 0
Accepted
time: 43ms
memory: 3768kb

input:

100000

output:

139804054

result:

ok 1 number(s): "139804054"

Test #8:

score: -100
Wrong Answer
time: 38ms
memory: 3772kb

input:

1000000

output:

521718269

result:

wrong answer 1st numbers differ - expected: '521718285', found: '521718269'