1 #include<iostream> 2 using namespace std ; 3 int main() 4 { 5 int n ; 6 while(cin >> n) { 7 int sum = 1<<n ; 8 cout << sum + 1 << endl ; 9 } 10 return 0 ; 11 }
1 #include <iostream> 2 #include <cmath> 3 using namespace std; 4 int main() 5 { 6 int t1 = 1,t2 = 0,t3 = 1,n; 7 cin>>n; 8 for(int i = 1; i <= n; ++i) 9 { 10 t3 += t2; 11 t2 = t1; 12 t1 = pow(2,i-1); 13 } 14 cout<<t1+t2+t3<<endl; 15 return 0; 16 }