题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2211
搜了n久,都是一个代码,来回复制粘贴,,,,,,
鄙人尚不太懂,贴个以纪念!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 |
#include <stdio.h> int fun( int
n, int k) { if (n==k) return
k; int
m=fun(n-n/k,k); return
(m-1)/(k-1)+m; } int main() { int
cas,n,k; scanf ( "%d" ,&cas); while (cas--) { scanf ( "%d%d" ,&n,&k); printf ( "%d\n" ,fun(n,k)); } } |
原文:http://www.cnblogs.com/ccccnzb/p/3636704.html