-
Notifications
You must be signed in to change notification settings - Fork 0
/
ASYMTILING
42 lines (35 loc) · 824 Bytes
/
ASYMTILING
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// MOD == 10 일 때 7 = 7, 13 = 3 (3 - 7 + 10)/10 = 4
#include <iostream>
#include <cstring>
#define MAX 100
#define MOD 1000000007
using namespace std;
int n, cache[MAX];
int tiling(int x){
if(x <= 1) return 1;
int &ret = cache[x];
if(ret != -1) return ret;
ret = (tiling(x - 1) + tiling(x - 2))%MOD;
return ret;
}
int symmetric(int x){
int ret;
if(x%2 == 1)
return ret = (tiling(x) - tiling(x/2) + MOD)%MOD;
ret = tiling(x);
ret = (ret - tiling(x/2) + MOD)%MOD;
ret = (ret - tiling(x/2-1) + MOD)%MOD;
return ret;
}
int main(){
memset(cache, -1, sizeof(cache));
int c;
cin >> c;
while(c--){
memset(cache, -1, sizeof(cache));
cin >> n;
int answer = symmetric(n);
cout << answer <<'\n';
}
return 0;
}