OJ-Problems-Source/HDOJ/2211_autoAC.cpp
2016-08-22 00:09:53 +08:00

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);
}