mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
46f6aa3fc4
2200-2299
25 lines
365 B
C++
25 lines
365 B
C++
#include<stdio.h>
|
|
int main()
|
|
{
|
|
int dfs(int n,int k);
|
|
int t;
|
|
int n,k;
|
|
scanf("%d",&t);
|
|
while(t--)
|
|
{
|
|
scanf("%d%d",&n,&k);
|
|
printf("%d\n",dfs(n,k));
|
|
}
|
|
return 0;
|
|
}
|
|
int dfs(int n,int k)
|
|
{
|
|
int num;
|
|
if(n==k)
|
|
{
|
|
return k;
|
|
}
|
|
num=dfs(n-n/k,k);
|
|
return ((num-1)/(k-1)+num);
|
|
}
|