import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
String m="";
long[] fact = new long[14];
fact[0] = 1;
fact[1] = 1;
for (int i = 2; i < fact.length; i++) {
fact[i] = fact[i - 1]*i;
}
while((m=br.readLine())!=null) {
String[]str=m.split(" ");
int n=Integer.parseInt(str[0]);
int k=Integer.parseInt(str[1]);
str=br.readLine().split(" ");
long temp=fact[n];
for(int i=0;i<str.length;i++){
int div=Integer.parseInt(str[i]);
if(div>1)
temp/=fact[div];
}
sb.append(temp).append("\n");
}
System.out.print(sb);
}
}
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
String m="";
long[] fact = new long[14];
fact[0] = 1;
fact[1] = 1;
for (int i = 2; i < fact.length; i++) {
fact[i] = fact[i - 1]*i;
}
while((m=br.readLine())!=null) {
String[]str=m.split(" ");
int n=Integer.parseInt(str[0]);
int k=Integer.parseInt(str[1]);
str=br.readLine().split(" ");
long temp=fact[n];
for(int i=0;i<str.length;i++){
int div=Integer.parseInt(str[i]);
if(div>1)
temp/=fact[div];
}
sb.append(temp).append("\n");
}
System.out.print(sb);
}
}
No comments:
Post a Comment