AlenAntonelli

Tetrrahedon 166/E

Oct 19th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. ///https://trello.com/c/r2Wlhzup/52-problem-166e-codeforces
  2. ///http://codeforces.com/problemset/problem/166/E
  3. #include <iostream>
  4. using namespace std;
  5. int main()
  6. {
  7.     unsigned long long A=0, D=1;
  8.     unsigned long long A0, D0;
  9.    
  10.     int n;
  11.     cin>>n;
  12.    
  13.     for (int i=1; i<=n; i++)
  14.     {
  15.         A0 = 2*A + D;
  16.         D0 = 3*A;
  17.        
  18.         A = A0%1000000007;
  19.         D = D0%1000000007;
  20.     }
  21.     cout<<D<<endl;
  22.    
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment