传送门:牛客
牛牛即将要参加考试,他学会了填答题卡。
可惜他竖着的答题卡填成了横着的 : (
好奇的他想知道对于 n 道题,每道题 n 个选项的答题卡 ( n * n 的矩阵 ),满足横答题卡和竖答题卡图形一致的方案数有多少种。
注:每道题只能选择一个选项,即 n * n 的矩阵中只能涂黑 n 个空。求横竖对称的方案数。
输入:
3
输出:
4
主要思路:
emmm,感觉这道题的递推关系还是比较巧妙的,第一眼我完全被哄住了,感觉这道题挺难啊,这种模拟肯定不行了,n十分的大,枚举必挂,应该有什么规律.然后
0分
dp[i]=dp[i-1]+dp[i-2]*(i-1)
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
#define root 1,n,1
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
inline ll read() {
ll x=0,w=1;char ch=getchar();
for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') w=-1;
for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
return x*w;
}
#define maxn 1000000
int f[100];
int main() {
int T;T=read();
f[1]=1;f[2]=2;
for(int i=3;i<=100;i++) f[i]=f[i-1]+f[i-2];
while(T--) {
int a;a=read();
printf("%d\n",f[a]);
}
return 0;
}