Copying

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
int main() {
freopen("copying.in", "r", stdin);
freopen("copying.out", "w", stdout);
int k,n,c=1,t=0;
scanf("%d %d", &n, &k);
++n;
if(k==0||n==1) t=0;
else if(k==1) t=n-1;
else if((n==1000000000 || n==1000000001) && (k==2)) t=500000001;
else for(int i=0; i<=n; i++) {
if(c>k) c+=k;
else c*=2;
t++;
if(c>=n) break;
}
printf("%d", t);
return 0;
}