-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path552.cpp
52 lines (47 loc) · 1.04 KB
/
552.cpp
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
class Solution {
public:
int checkRecord(int n) {
int MOD = 1e9 + 7;
if(n == 1) return 3;
long long all = 0;
long long al = 1;
long long ap = 1;
long long aa = 2;
long long nall = 1;
long long nal = 1;
long long nap = 2;
for(int i = 3; i <= n; i++) {
long long ALL = 0, AL = 0, AP = 0, AA = 0, NALL = 0, NAL = 0, NAP = 0;
AP += all;
AP += aa;
AL += aa;
ALL += al;
AP += al;
AP += ap;
AL += ap;
NAP += nall;
AA += nall;
NAP += nal;
AA += nal;
NALL += nal;
NAP += nap;
AA += nap;
NAL += nap;
all = ALL;
al = AL;
ap = AP;
aa = AA;
nall = NALL;
nal = NAL;
nap = NAP;
all %= MOD;
al %= MOD;
ap %= MOD;
aa %= MOD;
nall %= MOD;
nal %= MOD;
nap %= MOD;
}
return (all + al + ap + aa + nall + nal + nap) % MOD;
}
};