#include <stdio.h> #include <stdlib.h> int main() { int N,k,L,i,t; while(scanf("%d%d%d",&N,&k,&L)!=EOF) { if(N==k&&k==L&&L==0) { break; } for(i=0;i<N;i++) { if(i!=0&&i!=N-1) { t=k/2; if(k-t+k>L) { break; } k=k-t+k; } } printf("%d\n",k); } return 0; } |
Double click to view unformatted code.