标签:
--------------------------------------
每次的可能性公式如下:
AC代码:
1 import java.util.Scanner; 2 3 public class Main { 4 5 public static void main(String[] args) { 6 7 Scanner sc=new Scanner(System.in); 8 9 while(sc.hasNextInt()){ 10 11 int s=sc.nextInt(); 12 int n=sc.nextInt(); 13 14 while(n-->0){ 15 int a=sc.nextInt(); 16 System.out.print(c(s,a)+" "); 17 s-=a; 18 } 19 System.out.println(); 20 } 21 } 22 23 public static long c(int n,int m){ 24 long a=1; 25 for(int i=0;i<m;i++) a*=(n-i); 26 long b=1; 27 for(int i=2;i<=m;i++) b*=i; 28 return a/b; 29 } 30 31 }
题目来源: http://acm.nyist.net/JudgeOnline/problem.php?pid=872
标签:
原文地址:http://www.cnblogs.com/cc11001100/p/5862365.html