Skip to content

Commit

Permalink
Create CF2020A.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou-yidie authored Oct 21, 2024
1 parent 0412a1d commit 22b35ee
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions CF2020A.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <bits/stdc++.h>
using namespace std;
int jzzh(int x,int y){
string sum="";
int b;
string a;
while(x){
b=x%y;
a=to_string(b);
x/=y;
sum=a+sum;
}
return stoi(sum);
}
int main() {
int n,t,k,c;
cin>>t;
for(int i=0; i<t; i++) {
int count=0;
cin>>n>>k;
if(k==1){
cout<<n<<endl;
continue;
}
//c=jzzh(n,k);
while(n){
count += n % k;
n /= k;
}
cout<<count<<endl;
}
return 0;
}

0 comments on commit 22b35ee

Please sign in to comment.