标签:import 多少 string system ret div clear 避免 oid
1 import java.util.Scanner; 2 3 public class Test_3 { 4 public static int f(int m, int n) { 5 if (n == 0)// 如果还鞋为0时,出现尴尬 6 return 1; 7 else if (m < n)// 如果借鞋少于还鞋时,不出现尴尬 8 return 0; 9 10 return f(m - 1, n) + f(m, n - 1); 11 // 解释:::(1)如果第m+n个是还鞋,则有m-1个是还鞋,n个是借鞋,所以f(m-1,n); 12 // (2)如果第m+n个是借鞋,则有m个是还鞋,n-1个是借鞋,所以f(m,n-1); 13 } 14 15 public static void main(String[] args) { 16 Scanner sc = new Scanner(System.in); 17 int m = sc.nextInt(); 18 int n = sc.nextInt(); 19 int a = f(m, n); 20 System.out.println(a); 21 } 22 }
标签:import 多少 string system ret div clear 避免 oid
原文地址:http://www.cnblogs.com/limn/p/6525092.html