ccbeginner

UVa Q580

Dec 30th, 2019
105
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //UVa Q580
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.    
  5. int32_t main(){
  6.     int arr[31] = {1,2,4};
  7.     for(int i = 3; i <= 30; ++i)arr[i] = arr[i-1] + arr[i-2] + arr[i-3];
  8.     int n;
  9.     while(cin >> n){
  10.         if(n == 0)break;
  11.         cout << (1<<n) - arr[n] << '\n';
  12.     }
  13.     return 0;
  14. }
RAW Paste Data