#include <bits/stdc++.h> using namespace std; int fun(int n,int k,int l){ if(n==0) return k; if(k-k/2+k>l) return k; return fun(n-1,k-k/2+k,l); } int main() { int n,k,l; while(cin>>n>>k>>l) { if(n==0&&k==0&&l==0) break; if(n<2) { cout<<k<<endl; } else { int count = fun(n-2,k,l); cout<<count<<endl; } } return 0; } /* 10 2 10 1 3 10 2 5 10 */ |
Double click to view unformatted code.