185A.md (1570B)
1 Source: https://codeforces.com/problemset/problem/185/A 2 3 A. Plant 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 Dwarfs have planted a very interesting plant, which is a triangle directed "upwards". This plant has an amusing feature. After one year a triangle plant directed "upwards" divides into four triangle plants: three of them will point "upwards" and one will point "downwards". After another year, each triangle plant divides into four triangle plants: three of them will be directed in the same direction as the parent plant, and one of them will be directed in the opposite direction. Then each year the process repeats. The figure below illustrates this process. 22 23  24 25 Help the dwarfs find out how many triangle plants that point "upwards" will be in *n* years. 26 27 Input 28 29 The first line contains a single integer *n* (0 ≤ *n* ≤ 1018) — the number of full years when the plant grew. 30 31 Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier. 32 33 Output 34 35 Print a single integer — the remainder of dividing the number of plants that will point "upwards" in *n* years by 1000000007 (109 + 7). 36 37 Examples 38 39 Input 40 41 ``` 42 1 43 ``` 44 45 Output 46 47 ``` 48 3 49 ``` 50 51 Input 52 53 ``` 54 2 55 ``` 56 57 Output 58 59 ``` 60 10 61 ``` 62 63 Note 64 65 The first test sample corresponds to the second triangle on the figure in the statement. The second test sample corresponds to the third one.