氧中毒求助(患者症状:吸氧导致的 RE)
查看原帖
氧中毒求助(患者症状:吸氧导致的 RE)
335552
Christophe_楼主2022/8/5 00:06
// Problem: P1350 车的放置
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P1350
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL N=1e4+10,P=1e5+3;
inline LL read(){
    LL ret=0,f=1; 
	char ch=getchar();
    while(ch<'0'||ch>'9'){ if(ch=='-') f=-f; ch=getchar(); }
    while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
    return ret*f;
}
inline void write(LL x){        
    if(x<0){ putchar('-'); x=-x; }      
    if(x>9) write(x/10);     
    putchar(x%10+'0');     
}
LL a,b,c,d,k;
LL C[N][N],ans;
LL pre[N],pst[N];
void init(){
	LL mx=max(max(a,b),max(c,d));
	C[0][0]=1;
	for(LL i=1;i<=mx;++i){
		C[i][0]=C[i][i]=1;
		for(LL j=1;j<=i-1;++j) C[i][j]=(C[i-1][j]+C[i-1][j-1])%P;
	}
}
int main(){
	a=read(),b=read(),c=read(),d=read(),k=read();
	init();
	for(LL x=k-c;x<=min(a,k);++x){
		LL minu=k-d,maxu=min(min(b,k),x);
		pre[0]=x;
		for(LL i=1;i<=maxu-1;++i) pre[i]=pre[i-1]*(x-i)%P;
		pst[k]=1;
		for(LL i=k-1;i>=minu;--i) pst[i]=pst[i+1]*(k-i)%P;
		for(LL u=minu;u<=maxu;++u){
			LL v=k-u,y=k-x;
			LL lans=1,rans=1;
			if(u) lans=pre[u-1];
			rans=pst[u];
			(ans+=C[b][u]*C[d][v]*C[a][x]%P*C[c][y]*lans%P*rans)%=P;
		}
	}
	write(ans);
	return 0;
}

RT,这份代码不开 O2 可 AC,吸口氧 #2 和 #6 就 RE 了(数组已开最大)qwqqwq

2022/8/5 00:06
加载中...