report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Number counting - FlandreOJ: Flandre Online Judge

Number counting

Time limit: 1000 ms
Memory limit: 256 MB
How many $n$ digit number satisfy the following condition: $$i^{th} digit \equiv i \pmod{3}$$ Please note that the indexing starts from 1 at the leftmost digit. For example, $42$ satisfies the condition. ### Input - The first line contains an integer $n$. ### Output - Print the number of numbers satisfy the above condition, modulo $10^9+7$. ### Constraints - $1 \le n \le 10^{18}$. ### Example Input: ``` 2 ``` Output: ``` 9 ```
Binary exponentiation
Overflow
Binary exponentiation
Number counting
Topic
Math
Combinatorics
Rating 900
Solution (1) Solution