package 刷题.入门; import java.util.Scanner; public class Peter的烟 { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int n = scanner.nextInt(); int k = scanner.nextInt(); int res=get(n, k); System.out.println(res+n); } //返回n根烟 能兑换的根数 static int get(int n,int k) { if (n<k) { return 0; }else { //能兑换n/k return n/k+get(n%k+n/k, k); } } }