fork download
  1. #include<iostream>
  2. #include<vector>
  3. using namespace std;
  4.  
  5.  
  6. const int mod = 1e9+7;
  7.  
  8.  
  9. int solve(){
  10. int n;cin>>n;
  11. vector<vector<int>> dp(n+1, vector<int>(8, 0));
  12. for(int i=0;i<=5;++i){
  13. dp[1][i] = 1;
  14. }
  15. dp[1][6] = dp[1][7] = 0;
  16. for(int i=2;i<=n;++i){
  17. for(int j=0;j<=5;++j){
  18. for(int k=0;k<=7;++k){
  19. // cout<<i<<" "<<j<<" "<<(j^k)<<endl;
  20. dp[i][k] = (dp[i][k]%mod + dp[i-1][j^k]%mod)%mod;
  21. }
  22. }
  23. }
  24. cout<<dp[n][0]<<endl;
  25.  
  26. return 0;
  27. }
  28. int main(){
  29. int t=1;
  30. cin>>t;
  31. while(t--){
  32. solve();
  33. }
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0s 4380KB
stdin
60
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
stdout
1
6
28
168
976
5856
35008
210048
1259776
7558656
45349888
272099328
632587769
795526593
773126762
638760544
832432171
994592998
967033665
802201955
811114550
866687272
191734989
150409927
868905130
213430745
146366735
878200410
732331520
393989092
216450904
298705417
202297959
213787747
922988352
537930077
788627935
731767582
634795426
808772535
829395023
976370110
765259989
591559906
177516871
65101219
903237152
419422877
567056586
402339495
616114308
696685827
988424342
930546017
816513678
899082040
327442642
964655845
519736783
118420677