#include <stdio.h> #include <iostream> #include <string.h> #include <string> using namespace std; int fib(int n,int k,int l) { if (n == 2)return k; if (k - k / 2 + k >l) { return k; } k = k - k / 2 + k; //cout << k << " "; fib(n - 1, k, l); } int main() { int n, k, l; while (cin >> n >> k >> l) { if (n == 0 && k == 0 && l == 0) { break; } int t = fib(n, k, l); cout << t << endl; } } |
Double click to view unformatted code.