#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll n,p,t;
cin>>n>>p;
ll dp[200050],pre[200050];
dp[1]=1,pre[1]=1;
for(ll x=2;x<=n;x++)
{
ll flag=0;
t=sqrt(x);
dp[x]=(dp[x]+pre[x-1])%p;
for(ll z=2;z<=sqrt(x);z++)dp[x]=(dp[x]+dp[x/z])%p;
for(ll c=1;c<=sqrt(x);c++)
{
if(c==(ll)sqrt(x) && x/c<=sqrt(x))continue;
ll len=(x/c-x/(c+1));
dp[x]=(dp[x]+len*dp[c])%p;
}
pre[x]=(pre[x-1]+dp[x])%p;
}
printf("%lld",dp[n]);
return 0;
}
CF 1561D1 Up the Strip (simplified version)
猜你喜欢
转载自blog.csdn.net/Ambrumf/article/details/120900625
今日推荐
周排行