杀人游戏
结论推导学习:https://blog.csdn.net/u012717411/article/details/43925433
代码:
#include <bits/stdc++.h>
using namespace std;
int t, n, k;
int Recursion(int n, int k){
if(n==k)return k;
int x = Recursion(n-n/k, k);
return (x-1)/(k-1)+x;
}
int main(){
scanf("%d", &t);
while(t--){
scanf("%d %d", &n, &k);
printf("%d\n", Recursion(n, k));
}
return 0;
}