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
61
62
63
64
65
66
67
68 |
typedef
unsigned long
long LL ; map < int
, LL > fibo ; map < int
, LL > ::iterator it ; LL my_pow(LL x , LL y){ LL ans = 1 ; for (; y; y>>=1 ){ if (y&1) ans *= x ; x*=x ; } return
ans ; } void
init(){ fibo.clear() ; LL x1 = 4 ; LL x2 = 3 ; fibo[1] = 4 ; fibo[2] = 3 ; int
id = 3 ; while (x1 + x2 <= my_pow(2,63)){ fibo[id] = x1+ x2 ; id++ ; LL temp = x2 ; x2 = x1 + x2 ; x1 = temp ; } fibo[id] = x1+ x2 ; } char
dfs( int
id , LL n){ if (n <= 7){ switch (n){ case
1 : return
‘T‘ ; case
2 : return
‘.‘ ; case
3 : return
‘T‘ ; case
4 : return
‘^‘ ; case
5 : return
‘_‘ ; case
6 : return
‘_‘ ; case
7 : return
‘^‘
; } } LL x = fibo[id-1] ; if (x < n) return
dfs(id - 2 , n - x) ; else return
dfs(id - 1 , n ) ; } char
gao(LL n){ init() ; int
id ; for (it = fibo.begin() ; it != fibo.end() ; it++){ if (it->second >= n){ id = it->first ; break
; } } return
dfs(id , n) ; } |
原文:http://www.cnblogs.com/liyangtianmen/p/3584622.html