Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t;
- cin>>t;
- while(t--){
- int n,k,mod,mul,cnt=0;
- cin>>n>>k;
- while(n>=k){
- mod=n%k;
- mul=n/k;
- n=mul;
- n+=mod;
- cnt+=mul;
- }
- if(n==1){
- cout<<cnt<<endl;
- }
- else{
- cout<<"cannot do this"<<endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement