30pts求调
查看原帖
30pts求调
796776
MAX_CURRY_JAMES楼主2025/7/23 16:18
#include<bits/stdc++.h>
#define int long long
#define MOD 10007
//#pragma GCC optimize(2,"Ofast","inline")
using namespace std;
inline void read(int &x){
	bool neg=false;
	char ch=0;
	x=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-') neg=true;
		ch=getchar();
	}
	if(neg)
	while(ch>='0'&&ch<='9') {
		x=x*10+('0'-ch);
		ch=getchar();
	}
	else
	while(ch>='0'&&ch<='9') {
		x=x*10+(ch-'0');
		ch=getchar();
	}
}
inline void write(int x){
	bool neg=false;
	if(x<0){
		neg=true;
		putchar('-');
	}
	static int sta[40];
	int top=0;
	do{
		sta[top++]=x%10,x/=10;
	}while(x);
	if(neg)
	while(top) putchar('0'-sta[--top]);
	else
	while(top) putchar('0'+sta[--top]);
}
int n,m,x,sum=1;
int C(int x,int y){
	int ans=1;
	for(int i=x;i>=x-y+1;i--)
	ans*=i,ans%=MOD;
	for(int i=2;i<=y;i++)
	ans/=i;
	return ans%MOD;
} 
signed main(){
	read(n),read(m);
	for(int i=1;i<=m;i++){
		read(x);
		sum*=C(n,x),sum%=MOD,n-=x;
	}
	write(sum);
}


2025/7/23 16:18
加载中...