QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#797356 | #9553. The Hermit | HalloWorld | WA | 2ms | 5232kb | C++20 | 1.5kb | 2024-12-02 21:25:16 | 2024-12-02 21:25:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define SZ(x) ((int)(x).size())
#define debug(a) cout<<#a<<":"<<a<<endl
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
constexpr int N=100010;
constexpr int INF=2e9;
constexpr ll LLF=2e18;
constexpr ll mod=998244353;
constexpr int dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
ll powmod(ll a,ll b,ll mod=mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll inv(ll a){return powmod(a,mod-2);}
ll n,m,ans=0;
ll inv[N],inc[N];
void init(){
inc[0]=1; for(int i=1;i<N;i++) inc[i]=inc[i-1]*i%mod;
inv[N-1]=powmod(inc[N-1],mod-2);
for(int i=N-2;i>=1;i--) inv[i]=inv[i+1]*(i+1)%mod;
}
ll C(int a,int b){
if(b==0) return 1;
if (a<b) return 0; if (a==b) return 1;
return inc[a]*inv[a-b]%mod*inv[b]%mod;
}
ll f[N][31];
void solve() {
init();
cin>>m>>n;
ans=C(m,n)*n%mod;
rep(i,1,m) f[i][1]=1;
rep(i,2,30)rep(j,1,m){
for(int k=2;k*j<=m;k++){
f[k*j][i]=(f[k*j][i]+f[j][i-1])%mod;
}
}
rep(i,1,30)rep(j,1,m){
// cout<<j<<" "<<i<<" "<<f[j][i]<<"\n";
if(n-i>=0){
ll k=C((m/j)-1,n-i);
// cout<<j<<" "<<f[j][i]<<" "<<k<<'\n';
if((m/j)-1>=1) ans=(mod+ans-f[j][i]*C((m/j)-1,n-i)%mod)%mod;
else ans=(mod+ans-f[j][i])%mod;
}
}
cout<<ans<<'\n';
}
int main() {
ios::sync_with_stdio(false);cin.tie(nullptr);
//cout<<fixed<<setprecision(10);
// int testcase;cin>>testcase;rep(_,1,testcase){
solve();
// }
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 5232kb
input:
4 3
output:
2
result:
wrong answer 1st numbers differ - expected: '7', found: '2'