--------------------------------------

每次的可能性公式如下:

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

转载于:https://www.cnblogs.com/cc11001100/p/5862365.html

Logo

昇腾计算产业是基于昇腾系列(HUAWEI Ascend)处理器和基础软件构建的全栈 AI计算基础设施、行业应用及服务,https://devpress.csdn.net/organization/setting/general/146749包括昇腾系列处理器、系列硬件、CANN、AI计算框架、应用使能、开发工具链、管理运维工具、行业应用及服务等全产业链

更多推荐