Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int T,n,m,ans;
- scanf("%d",&T);
- while(T--)
- {
- scanf("%d%d",&n,&m);
- ans=0;
- while(n>=m)
- {
- ans+=n/m;
- n=n/m+n%m;
- }
- if(n==1) printf("%d\n",ans);
- else printf("cannot do this\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment