QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#252373 | #6740. Function | ucup-team191# | AC ✓ | 90ms | 14740kb | C++14 | 1.5kb | 2023-11-15 18:55:43 | 2023-11-15 18:55:43 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using vl=vector<ll>;
#define pb push_back
#define all(a) begin(a),end(a)
const int N=3000010,MOD=998244353;
const char en='\n';
const ll LLINF=1ll<<60;
void ad(int&a,int b)
{
a+=b;
if (a>=MOD) a-=MOD;
}
inline int add(int A, int B) {
if(A + B >= MOD) return A + B - MOD;
return A + B;
}
inline int sub(int A, int B) {
if(A - B < 0) return A - B + MOD;
return A - B;
}
inline int mul(int A, int B) {
return (long long)A * B % MOD;
}
int n,getInd[N];
vi vals;
vi dp;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n;
for (int i=1;i*i<=n;++i) vals.pb(i),vals.pb(n/i);
sort(all(vals));
vals.erase(unique(all(vals)),vals.end());
unordered_map<int,int> um;
for (int i=0;i<(int)vals.size();++i) if (vals[i]<N) getInd[vals[i]]=i;
else um[vals[i]]=i;
for (int i=0;i<(int)vals.size();++i)
{
int cu=vals[i],an=1,lo=1,hi=1;
if (cu>1) for (int j=1;j*j<=cu;++j)
{
//floor(cu/x)=j
lo=cu/(j+1)+1,hi=cu/j;
hi=min(hi,20210926);
lo=max(lo,2);
if (lo>hi) continue;
//cout<<cu<<' '<<lo<<' '<<hi<<' '<<j<<endl;
ad(an,mul(hi-lo+1,dp[getInd[j]]));
}
for (int j=2;j<lo;++j)
{
int uz=cu/j,in;
if (uz<N) in=getInd[uz];
else in=um[uz];
//cout<<uz<<' '<<in<<' '<<dp[in]<<en;
ad(an,dp[in]);
}
//cout<<cu<<' '<<an<<en;
dp.pb(an);
}
cout<<dp.back()<<en;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3420kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3480kb
input:
2
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3408kb
input:
100
output:
949
result:
ok 1 number(s): "949"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3372kb
input:
10
output:
19
result:
ok 1 number(s): "19"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3404kb
input:
1000
output:
48614
result:
ok 1 number(s): "48614"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3392kb
input:
10000
output:
2602393
result:
ok 1 number(s): "2602393"
Test #7:
score: 0
Accepted
time: 1ms
memory: 3540kb
input:
100000
output:
139804054
result:
ok 1 number(s): "139804054"
Test #8:
score: 0
Accepted
time: 2ms
memory: 7784kb
input:
1000000
output:
521718285
result:
ok 1 number(s): "521718285"
Test #9:
score: 0
Accepted
time: 4ms
memory: 8368kb
input:
10000000
output:
503104917
result:
ok 1 number(s): "503104917"
Test #10:
score: 0
Accepted
time: 17ms
memory: 5908kb
input:
100000000
output:
198815604
result:
ok 1 number(s): "198815604"
Test #11:
score: 0
Accepted
time: 90ms
memory: 10316kb
input:
1000000000
output:
373787809
result:
ok 1 number(s): "373787809"
Test #12:
score: 0
Accepted
time: 86ms
memory: 10288kb
input:
999999999
output:
997616263
result:
ok 1 number(s): "997616263"
Test #13:
score: 0
Accepted
time: 86ms
memory: 10528kb
input:
999999990
output:
997615701
result:
ok 1 number(s): "997615701"
Test #14:
score: 0
Accepted
time: 86ms
memory: 10436kb
input:
999999900
output:
993928691
result:
ok 1 number(s): "993928691"
Test #15:
score: 0
Accepted
time: 86ms
memory: 13200kb
input:
999999000
output:
754532207
result:
ok 1 number(s): "754532207"
Test #16:
score: 0
Accepted
time: 90ms
memory: 14740kb
input:
999990000
output:
996592686
result:
ok 1 number(s): "996592686"
Test #17:
score: 0
Accepted
time: 86ms
memory: 11980kb
input:
999900000
output:
311678722
result:
ok 1 number(s): "311678722"
Test #18:
score: 0
Accepted
time: 89ms
memory: 12172kb
input:
999000000
output:
60462624
result:
ok 1 number(s): "60462624"
Test #19:
score: 0
Accepted
time: 86ms
memory: 12168kb
input:
990000000
output:
444576800
result:
ok 1 number(s): "444576800"
Test #20:
score: 0
Accepted
time: 83ms
memory: 11700kb
input:
900000000
output:
95615129
result:
ok 1 number(s): "95615129"
Test #21:
score: 0
Accepted
time: 0ms
memory: 7876kb
input:
1361956
output:
813433539
result:
ok 1 number(s): "813433539"
Test #22:
score: 0
Accepted
time: 4ms
memory: 10104kb
input:
7579013
output:
677659797
result:
ok 1 number(s): "677659797"
Test #23:
score: 0
Accepted
time: 0ms
memory: 11916kb
input:
8145517
output:
801509527
result:
ok 1 number(s): "801509527"
Test #24:
score: 0
Accepted
time: 0ms
memory: 10236kb
input:
6140463
output:
869023935
result:
ok 1 number(s): "869023935"
Test #25:
score: 0
Accepted
time: 3ms
memory: 10012kb
input:
3515281
output:
989091505
result:
ok 1 number(s): "989091505"
Test #26:
score: 0
Accepted
time: 4ms
memory: 10176kb
input:
6969586
output:
539840131
result:
ok 1 number(s): "539840131"