QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#797344#9553. The HermitHalloWorldWA 292ms29484kbC++201.4kb2024-12-02 21:12:402024-12-02 21:12:40

Judging History

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

  • [2024-12-02 21:12:40]
  • 评测
  • 测评结果:WA
  • 用时:292ms
  • 内存:29484kb
  • [2024-12-02 21:12:40]
  • 提交

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 (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";
		ans=(mod+ans-f[j][i]*C((m/j)-1,n-i)%mod)%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;	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 6912kb

input:

4 3

output:

7

result:

ok 1 number(s): "7"

Test #2:

score: 0
Accepted
time: 3ms
memory: 7140kb

input:

11 4

output:

1187

result:

ok 1 number(s): "1187"

Test #3:

score: 0
Accepted
time: 223ms
memory: 29420kb

input:

100000 99999

output:

17356471

result:

ok 1 number(s): "17356471"

Test #4:

score: 0
Accepted
time: 7ms
memory: 8556kb

input:

11451 1919

output:

845616153

result:

ok 1 number(s): "845616153"

Test #5:

score: 0
Accepted
time: 212ms
memory: 29400kb

input:

99998 12345

output:

936396560

result:

ok 1 number(s): "936396560"

Test #6:

score: -100
Wrong Answer
time: 292ms
memory: 29484kb

input:

100000 1

output:

183154093

result:

wrong answer 1st numbers differ - expected: '0', found: '183154093'