0
点赞
收藏
分享

微信扫一扫

小V和方程

​​小V和方程​​

需要用到的知识:​​小球与盒子​​

冷静分析,仔细思考

// Created by CAD on 2020/5/15.
#include <bits/stdc++.h>

#define ll long long
using namespace std;

const int mod=998244353;
const int maxn=1005;
ll f[maxn][maxn];

ll solve(ll n,ll m){
if(n<=1||m==1) return 1;
else if(m==0) return 0;
else if(n<m) return f[n][n]?f[n][n]:f[n][n]=solve(n,n);
else return f[n][m]?f[n][m]:f[n][m]=((solve(n,m-1)+solve(n-m,m)))%mod;
}

int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n,m;cin>>n>>m;
ll x=1;
for(ll i=2;i*i<=m;++i)
while(m%(i*i)==0)
x*=i,m/=(i*i);
cout<<(solve(x,n)%mod+mod)%mod<<"\n";
return 0;
}

CAD加油!欢迎跟我一起讨论学习算法


举报

相关推荐

0 条评论