Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <cstring>
- #include <conio.h>
- using namespace std;
- int _count(int n, int k){
- int ans = n/k;
- if(ans>=k)
- return ans +_count(ans, k);
- return ans;
- }
- int main(){
- int n, k, ans;
- char a[10];
- while(scanf("%d %d", &n, &k)!= EOF){
- ans = n +_count(n, k);
- printf("%d\n", ans);
- fflush(stdin);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement