f(n,k) = f(n - k,k) * n n > k
f(n,k) = n n <= k
1 import java.util.Scanner; 2 3 public class P1083 4 { 5 public static int caculate(int n, int k) 6 { 7 if (n <= k) 8 return n; 9 return n * caculate(n - k, k); 10 } 11 12 public static void main(String args[]) 13 { 14 try (Scanner cin = new Scanner(System.in)) 15 { 16 while (cin.hasNext()) 17 { 18 int n = cin.nextInt(); 19 int k = cin.next().length(); 20 System.out.println(caculate(n, k)); 21 } 22 } 23 } 24 }
时间: 2024-10-20 19:19:13