Advertisement
Graf_Rav

111 podryad

May 23rd, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.     int n;
  7.     cin>>n;
  8.    
  9.     if(n==1){
  10.         cout<<3;
  11.         return 0;
  12.     }
  13.     else if(n==2){
  14.         cout<<9;
  15.         return 0;
  16.     }
  17.     else if(n==3){
  18.         cout<<26;
  19.         return 0;
  20.     }
  21.    
  22.     int x11=2;
  23.     int xx1=6;
  24.     int last=26;
  25.    
  26.     for(int i=4;i<=n;i++){
  27.         int x11_1=xx1;
  28.         int xx1_1=last-xx1-x11;
  29.         int last_1=last*2+(last-x11);
  30.         x11=x11_1;
  31.         xx1=xx1_1;
  32.         last=last_1;
  33.     }
  34.     cout<<last;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement