QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#164883#6740. Functionxaphoenix#AC ✓605ms3992kbC++141.7kb2023-09-05 14:24:192023-09-05 14:24:20

Judging History

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

  • [2023-09-05 14:24:20]
  • 评测
  • 测评结果:AC
  • 用时:605ms
  • 内存:3992kb
  • [2023-09-05 14:24:19]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define LC k<<1
#define RC k<<1|1
#define IO cin.sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repn(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = (n) - 1; i >= a; i--)
#define pern(i, a, n) for (int i = n; i >= a; i--)

typedef long long LL;
typedef long double LD;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef pair<double, double> PDD;
typedef pair<ull, ull> PUU;
typedef pair<LL, LL> PLL;

const int N = 110000;
const int M = 1100000;
const int mod = 998244353;
const int inf = (int)1e9;
const LL INF = 1e18;
const double eps = 1e-9;

mt19937_64 Rand((unsigned long long)new char);
#define rand Rand

int n, lim;
int f[N], g[N];
const int L = 20210926;
int dfs(LL x) {
	if (x > n) return 0;
	if (x > 50) x = n / (n / x);
	if (x <= lim && f[x]) return f[x];
	else if (x > lim && g[n / x]) return g[n / x];
	int res = 1, l = 2, r, d = n / x;
	while ((LL)l * x <= 50) res = (res + dfs(l * x)) % mod, l++;
	d = min(d, L);
	while (l <= d) {
		r = min((LL)d, n / (n / (l * x)) / x);
		LL num = (r - l + 1) % mod;
		num = num * dfs(l * x) % mod;
		res = (res + num) % mod;
		l = r + 1;
	}
	if (x <= lim) return f[x] = res;
	else return g[n / x] = res;
}
int main() {
	IO;
	cin >> n;
	// n = 1000000000;
	lim = int(sqrt(n) + 0.1);
	cout << dfs(1) << "\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

2

output:

2

result:

ok 1 number(s): "2"

Test #3:

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

input:

100

output:

949

result:

ok 1 number(s): "949"

Test #4:

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

input:

10

output:

19

result:

ok 1 number(s): "19"

Test #5:

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

input:

1000

output:

48614

result:

ok 1 number(s): "48614"

Test #6:

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

input:

10000

output:

2602393

result:

ok 1 number(s): "2602393"

Test #7:

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

input:

100000

output:

139804054

result:

ok 1 number(s): "139804054"

Test #8:

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

input:

1000000

output:

521718285

result:

ok 1 number(s): "521718285"

Test #9:

score: 0
Accepted
time: 20ms
memory: 3684kb

input:

10000000

output:

503104917

result:

ok 1 number(s): "503104917"

Test #10:

score: 0
Accepted
time: 107ms
memory: 3796kb

input:

100000000

output:

198815604

result:

ok 1 number(s): "198815604"

Test #11:

score: 0
Accepted
time: 604ms
memory: 3928kb

input:

1000000000

output:

373787809

result:

ok 1 number(s): "373787809"

Test #12:

score: 0
Accepted
time: 600ms
memory: 3848kb

input:

999999999

output:

997616263

result:

ok 1 number(s): "997616263"

Test #13:

score: 0
Accepted
time: 600ms
memory: 3848kb

input:

999999990

output:

997615701

result:

ok 1 number(s): "997615701"

Test #14:

score: 0
Accepted
time: 605ms
memory: 3992kb

input:

999999900

output:

993928691

result:

ok 1 number(s): "993928691"

Test #15:

score: 0
Accepted
time: 605ms
memory: 3852kb

input:

999999000

output:

754532207

result:

ok 1 number(s): "754532207"

Test #16:

score: 0
Accepted
time: 604ms
memory: 3972kb

input:

999990000

output:

996592686

result:

ok 1 number(s): "996592686"

Test #17:

score: 0
Accepted
time: 605ms
memory: 3840kb

input:

999900000

output:

311678722

result:

ok 1 number(s): "311678722"

Test #18:

score: 0
Accepted
time: 604ms
memory: 3932kb

input:

999000000

output:

60462624

result:

ok 1 number(s): "60462624"

Test #19:

score: 0
Accepted
time: 599ms
memory: 3892kb

input:

990000000

output:

444576800

result:

ok 1 number(s): "444576800"

Test #20:

score: 0
Accepted
time: 558ms
memory: 3908kb

input:

900000000

output:

95615129

result:

ok 1 number(s): "95615129"

Test #21:

score: 0
Accepted
time: 5ms
memory: 3672kb

input:

1361956

output:

813433539

result:

ok 1 number(s): "813433539"

Test #22:

score: 0
Accepted
time: 16ms
memory: 3684kb

input:

7579013

output:

677659797

result:

ok 1 number(s): "677659797"

Test #23:

score: 0
Accepted
time: 17ms
memory: 3752kb

input:

8145517

output:

801509527

result:

ok 1 number(s): "801509527"

Test #24:

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

input:

6140463

output:

869023935

result:

ok 1 number(s): "869023935"

Test #25:

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

input:

3515281

output:

989091505

result:

ok 1 number(s): "989091505"

Test #26:

score: 0
Accepted
time: 11ms
memory: 3684kb

input:

6969586

output:

539840131

result:

ok 1 number(s): "539840131"