SP2530 GNY07H - Tiling a Grid With Dominoes 题解
作者:互联网
就喜欢找这种紫题来做,一看,排列组合,就想到了打表。
正如楼上的题解所说,OEIS是个好东西,从中找出一串序列,然后打个表,一道紫题就轻松地AC啦!!
0, 1, 1, 5, 11, 36, 95, 281, 781, 2245, 6336,18061, 51205, 145601, 413351, 1174500, 3335651,9475901, 26915305, 76455961, 217172736,616891945, 1752296281, 4977472781,14138673395, 40161441636,114079985111,324048393905
把这串数放到数组里,然后在和边长一对照,就发现输出a[w+2]a[w+2]就可以啦。
AC CODE
#include<bits/stdc++.h>
using namespace std;
long long n,x,a[30]={0,0, 1, 1, 5, 11, 36, 95, 281, 781, 2245, 6336, 18061, 51205, 145601, 413351, 1174500, 3335651, 9475901, 26915305, 76455961, 217172736, 616891945, 1752296281, 4977472781, 14138673395, 40161441636,114079985111,324048393905} ;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>x;
cout<<i<<" "<<a[x+2]<<"\n";
}
return 0;
}
标签:GNY07H,int,题解,long,1752296281,Grid,3335651,51205 来源: https://www.cnblogs.com/cancangqiongkk/p/16676277.html