首页 > 其他 > 详细

NYOJ题目872开会

时间:2016-09-11 20:14:40      阅读:184      评论:0      收藏:0      [点我收藏+]

技术分享

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

每次的可能性公式如下:

技术分享

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

NYOJ题目872开会

原文:http://www.cnblogs.com/cc11001100/p/5862365.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!