Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //first we have to find the prime factorization count of that number
- //we have to found out count after ncr calculation
- //then add 1 with the count
- //calculate if need more
- #include<stdio.h>
- #define ll long long
- int prime[90], range=0;
- int vis[500];
- void inti(){
- int i,j;
- for(i=2; i*i<=431; i++){
- if(vis[i]==0){
- for(j=i*i;j<=431;j+=i){
- vis[j]=1;
- }
- }
- }
- for(i=2;i<=431;i++){
- if(vis[i]==0){
- //printf("%d\n", i);
- prime[range++]=i;
- }
- }
- }
- int cal(int n, int p){
- if(n<p) return 0;
- else return(n/p + cal(n/p, p));
- }
- int main(){
- //inti();
- int n,k,i;
- __int64 result =1,pre;
- inti();
- //printf("%d\n", range);
- while(scanf("%d%d",&n,&k)==2){
- result=1;
- if(k==0||k==n){
- printf("1\n");
- continue;
- }
- for(i=0;i<range&&prime[i]<=n;i++){
- pre=cal(n,prime[i]) - cal(n-k,prime[i]) - cal(k,prime[i]);
- result = result * (pre+1);
- }
- printf("%I64d\n", result);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement