QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#417350#6736. Alice and Bobericmegalovania#Compile Error//C++201.4kb2024-05-22 17:49:112024-05-22 17:49:12

Judging History

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

  • [2024-05-22 17:49:12]
  • 评测
  • [2024-05-22 17:49:11]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

//#define ONLINE
#ifndef ONLINE
#define debug(...) fprintf(stderr,##__VA_ARGS__)
#else
#define debug(...) ;
#endif

using LL=long long;
using PII=pair<int,int>;

template<typename T>
inline T READ(){
	T x=0; bool f=0; char c=getchar();
	while(!isdigit(c)) f|=(c=='-'),c=getchar();
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
	return f?-x:x;
}
inline int read(){return READ<int>();}
inline LL readLL(){return READ<LL>();}
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int mod=998244353;
LL ksm(LL a,LL b){
	a%=mod; LL ret=1;
	while(b){
		if(b&1) ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret;
}

#define N 10000010
namespace Fac{//factorial
	LL fc[N]={1},fc_inv[N]={1};
	void init(){
		for(int i=1;i<N;i++){
			fc[i]=fc[i-1]*i%mod;
			fc_inv[i]=fc_inv[i-1]*ksm(i,mod-2)%mod;
		}
	}
	LL F(const int& x){
		return fc[x];
	}
	LL P(const int& x,const int& y){
		return fc[x]*fc_inv[x-y]%mod;
	}
	LL C(const int& x,const int& y){
		return fc[x]*fc_inv[y]%mod*fc_inv[x-y]%mod;
	}
}

int main(){
	Fac::init();
	int n=read(); LL ans=0;
	for(int i=1;i<=n;i++){
		ans=(ans+(Fac::P(n-i,i-1)*Fac::F(n-i)%mod))%mod;
	}
	printf("%lld",ans);
	return 0;
}

/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
*/

Details

/tmp/ccWw4D0O.s: Assembler messages:
/tmp/ccWw4D0O.s: Fatal error: can't write 60 bytes to section .text of /tmp/ccHl1a6N.o: 'File too large'
/tmp/ccWw4D0O.s: Fatal error: can't close /tmp/ccHl1a6N.o: File too large