Skip to content

Instantly share code, notes, and snippets.

@EragonJ
Created December 4, 2009 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EragonJ/249248 to your computer and use it in GitHub Desktop.
Save EragonJ/249248 to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<stdlib.h>
long long int a;
long long int set(int);
int main(){
int k,n;
int i;
int *ptr;
while(scanf("%d %d",&k,&n)==2){
ptr = (int*)malloc(sizeof(int)*n);
for(i=0;i<n;i++){
scanf("%d",&ptr[i]);
}
a = set(k);
for(i=0;i<n;i++){
a = a / set(ptr[i]);
}
printf("%lld\n",a);
free(ptr);
}
return 0;
}
long long int set(int n){
if(n<=1){
return 1;
}else{
return n*set(n-1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment