桂林有N个不同的文件,现在他要创建N-1个文件夹(相同)来保存这些文件,每个文件夹内有且只有两个项目,每个项目可以是一个文件或者一个文件夹,问他有多少种不同的存储方式。
第一行一个正整数T,表示数据组数。
接下来T行每行一个正整数N。
共T行,在模19260817的意义下桂林的存储方式总数。
2
3
5
3
105
时间:1s 空间:256M
30%的数据:2≤N≤20;
70%的数据:2≤N≤1000;
100%的数据:T≤100, 2≤N≤10^6
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
int read(){
int a=0,b=1;
char ch=getchar();
while((ch<48||ch>57)&&ch!=‘-‘){
ch=getchar();
}
if(ch==‘-‘){
b=-1;
ch=getchar();
}
while(ch<48||ch>57){
ch=getchar();
}
while(ch>47&&ch<58){
a=a*10+ch-48;
ch=getchar();
}
return a*b;
}
int t,n;
long long x[2000610];
int main(){
x[0]=x[1]=1;
for(int i=2;i<=2000610;i++){
x[i]=x[i-2]*i%19260817;
}
t=read();
while(t--){
n=read();
printf("%d\n",x[2*n-3]);
}
return 0;
}
原文:https://www.cnblogs.com/xiongchongwen/p/11478687.html