Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- long long int n,k,a,b,c,d,e,z,rem;
- while(scanf("%lld%lld",&n,&k)!=EOF)
- {
- z=n;
- c=0;
- while(n>=k)
- {
- rem=n%k;
- a=rem;
- b=n/k;
- c=c+b;
- n=a+b;
- }
- d=z+c;
- if(n>=k)
- {
- e=n/k;
- printf("%lld\n",d+e);
- }
- else
- {
- printf("%lld\n",d);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment