5263 - Problem S4: Interesting Numbers 加强版  

  We call a number interesting, if and only if:
  1. Its digits consists of only 0, 1, 2 and 3, and all these digits occurred at least once.
  2. Inside this number, all 0s occur before any 1s, and all 2s occur before any 3s.
  Therefore, the smallest interesting number according to our definition is 2013. There are two more interseting number of 4 digits: 2031 and 2301.
  Your task is to calculate the number of interesting numbers of exactly n digits. As the answer might be very large, you only need to output the answer modulo 1000000007.
 

输入

  The input has one line consisting of one positive integer n (4 ≤ n ≤ 10^15).
 

输出

  The output has just one line, containing the number of interesting numbers of exactly n digits, modulo 1000000007.
 

样例

输入

4

输出

3

来源

蓝桥杯

时间限制 1 秒
内存限制 256 MB
讨论 统计
上一题 下一题