标签:
1 #include<stdio.h> 2 int cal(int n,int k) 3 { 4 if(n==k)return k; 5 int m = cal(n-n/k,k); 6 return (m-1)/(k-1)+m; 7 } 8 int main() 9 { 10 int t,n,k; 11 scanf("%d",&t); 12 while(t--) 13 { 14 scanf("%d%d",&n,&k); 15 printf("%d\n",cal(n,k)); 16 } 17 return 0; 18 }
标签:
原文地址:http://www.cnblogs.com/isole/p/5774461.html