Functon f is defined as: f(n) = 3*f(n-1)+4 and f(1) = 1
That is,
f(2) = 3*f(1)+4 = 3*1+4 = 7
f(3) = 3*f(2)+4 = 3*7+4 = 25
f(4) = 3*f(3)+4 = 3*25+4 =79
...
Given an integer n, please calculate the reminder of f(n) divided by 10^9+9, i.e., f(n) mod (10^9+9).
Each test case is on a line, containing only one integer, n, where 0 < n < 2^63. The number of test cases is smaller than or equal to 1000. The input is terminated by end-of-file (EOF).
For each test case, output the reminder of f(n) divided by 10^9+9, i.e., f(n) mod (10^9+9), on a separate line.
範例輸入 1
1 2 3 4
範例輸出 1
1 7 25 79
Pro 專屬功能: 查看這題在歷屆 CPE 出現過幾次 — 升級以解鎖.