Advertisement
benyeh

Untitled

Apr 8th, 2013
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdio>
  4. #include <cstdlib>
  5. #include <string>
  6. using namespace std;
  7.  
  8. void rec_count(unsigned long long &count, int A, int B, int n){
  9.     // A >= B
  10.     if(A == n) count++;
  11.     else if(A == B) rec_count(count, A+1, B, n);
  12.     else if(A > B){
  13.         rec_count(count, A+1, B, n);
  14.         rec_count(count, A, B+1, n);
  15.     }
  16. }
  17.  
  18. int main() {
  19.     string filename;
  20.     cin >> filename;
  21.     ifstream inputFile(filename.c_str());
  22.     int t, n;
  23.     unsigned long long count;
  24.     inputFile >> t;
  25.     cout << t << endl;
  26.     for(int i = 0; i < t; i++){
  27.         count = 0;
  28.         inputFile >> n;
  29.         rec_count(count, 1, 0, n);
  30.         cout << count << endl;
  31.     }
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement