QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#138164#6740. FunctionNicolas125841ML 42ms3756kbC++171.1kb2023-08-11 02:27:282023-08-11 02:27:30

Judging History

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

  • [2023-08-11 02:27:30]
  • 评测
  • 测评结果:ML
  • 用时:42ms
  • 内存:3756kb
  • [2023-08-11 02:27:28]
  • 提交

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 = 1, ub; i <= n; 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";
}

詳細信息

Test #1:

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

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

2

output:

2

result:

ok 1 number(s): "2"

Test #3:

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

input:

100

output:

949

result:

ok 1 number(s): "949"

Test #4:

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

input:

10

output:

19

result:

ok 1 number(s): "19"

Test #5:

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

input:

1000

output:

48614

result:

ok 1 number(s): "48614"

Test #6:

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

input:

10000

output:

2602393

result:

ok 1 number(s): "2602393"

Test #7:

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

input:

100000

output:

139804054

result:

ok 1 number(s): "139804054"

Test #8:

score: -100
Memory Limit Exceeded

input:

1000000

output:


result: