QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#878936#9553. The Hermitucup-team134#Compile Error//C++141.7kb2025-02-01 19:05:582025-02-01 19:05:58

Judging History

This is the latest submission verdict.

  • [2025-02-01 19:05:58]
  • Judged
  • [2025-02-01 19:05:58]
  • Submitted

answer

#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ld long double

using namespace std;

mt19937 rng(time(NULL));

const int mod=998244353;
int add(int a,int b){
    a+=b;
    if(a>=mod)
        a-=mod;
    return a;
}
int sub(int a,int b){
    a-=b;
    if(a<0)
        a+=mod;
    return a;
}
int mul(int a,int b){
    return (long long)a*b%mod;
}
int pwrmod(int x,int k){
    int ans=1;
    for(;k;k>>=1,x=mul(x,x))
        if(k&1)
            ans=mul(ans,x);
    return ans;
}
int inv(int x){
	return pwrmod(x,mod-2);
}
const int N=1e5+5,L=17;
vector<int> fact(N),ifact(N);
void init(){
	fact[0]=1;
	for(int i=1;i<N;i++)
		fact[i]=mul(fact[i-1],i);
	ifact[N-1]=pwrmod(fact[N-1],mod-2);
	for(int i=N-2;i>=0;i--)
		ifact[i]=mul(ifact[i+1],i+1);
}
int nck(int n,int k){
	if(n<0||k<0||n<k)return 0;
	return mul(mul(fact[n],ifact[k]),ifact[n-k]);
}
int main()
{
	init();
	int n,m;
	cin >> n >> m;
	int total=mul(m,nck(n,m));
	vector dp(n+1,vector(L,0));
	vector<vector<int>> manji(n+1);
	vector<int> veci(n+1);
	for(int i=1;i<=n;i++){
		for(int j=2*i;j<=n;j+=i){
			manji[j].pb(i);
			veci[i]++;
		}
	}
	for(int i=1;i<=n;i++){
		for(int k=0;k<L;k++){
			dp[i][k]=0;
			if(k==0){
				dp[i][k]=1;
			}
			else{
				for(auto p:manji[i]){
					dp[i][k]=add(dp[i][k],dp[p][k-1]);
				}
			}
			int trebaJos=m-k-1;
			if(trebaJos>=0&&trebaJos<=veci[i]){
				total=sub(total,mul(dp[i][k],nck(veci[i],trebaJos)));
			}
		}
	}
	cout << total << endl;
	return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:63:16: error: missing template arguments before ‘dp’
   63 |         vector dp(n+1,vector(L,0));
      |                ^~
answer.code:74:25: error: ‘dp’ was not declared in this scope; did you mean ‘dup’?
   74 |                         dp[i][k]=0;
      |                         ^~
      |                         dup