• Loading...

Problem 6: Sigma Sigma Everywhere

Points:

Small Case: 5 Answer: 64332645

Large Case: 10 Answer: 33570795

Given the values of n, p, i and j, Find

(sigma(n,kp=0)sigma(kp,kp-1=0)...sigma(k2,k1=0) kiCj)%100000007

where

aCb = a!/(b!*(a-b)!)

Small Case: n=100, p=5, i=3, j=2
Large Case: n=10000, p=200, i=50, j=40

Solution:

The above summation is given by:

(sigma(n,kp=0)sigma(kp,kp-1=0)...sigma(k2,k1=0) kiCj)%100000007=(j+i-1)C(i-1)*(n+p)C(p+j)

Reference: Journal of Integer Sequences, Vol. 13 (2010), Article 10.4.4, Section 2

Code:




#include<iostream>

#include<cmath>

using namespace std;



#define MOD 100000007



int primes[1253]={2, 3, 5, 7, 11, 13, 17, 19, 23};



void genPrime(){

	int n=4,k,count=0;

	float check;

	bool flag=false;

	for(int i=9;i<=10200;i+=2)

	{

		check=sqrt((double)i);

	        for(k=0;primes[k]<=check;k++)

	        {

	          if(i%primes[k]==0)

	          {

	             flag=false;

	             break;

	          }

	          else

	             flag=true;

	       }

       if(flag==true){

          primes[n++]=i;

          }

       }

	primes[n]=10211;

}



long long nck(int n, int k)

{

	long long int result=1LL;

	long long int  tempn,tempk,tempnk,i,j;

	long long int  count[1252]={0};

	for(i=0;i<1252 && primes[i]<=n;i++){

		tempn=n;

		tempk=k;

		tempnk=n-k;

		while(tempn!=1 && primes[i]<=tempn){

			tempn=tempn/primes[i];

			count[i]+=tempn;

			}

		while(tempk!=1 && primes[i]<=tempk){

			tempk=tempk/primes[i];

			count[i]-=tempk;

			

		}

		while(tempnk!=1 && primes[i]<=tempnk){

			tempnk=tempnk/primes[i];

			count[i]-=tempnk;

		}

	}

	for(j=0;j<i;j++){

		long long int  po;

		if(count>0){

			po=(long long int )(pow((double)primes[j],(double)count[j]));

			result=(result*(po%MOD))%MOD;

		}

	}

	

return result;

}



int main(){

	long long int n,p,i,j,ans;

	n=10000, p=200, i=50, j=40;

	genPrime();

	ans=(nck(j+i-1,i-1)*nck(n+p,p+j))%MOD;

	cout<<ans<<endl;

	return 0;

}



Submit your solution

You need to be logged in to submit a solution.

discussions


porshRepresentation Unclear
Q:Can you please explain the output for n=2,p=2,i=1,j=1?
A:for n=2,p=2,i=1,j=1 sum=C(1,1)+C(1,1)+C(2,1)=4. C(n,r) for n<r is not defined so you don\'t have to consider those.

post a question

Loading...

Problem 1
Problem 2
Problem 3
Problem 4
Problem 5 (bonus) Expired
Problem 1
Problem 2
Problem 3
Problem 4 (bonus) Expired
Top Scorers
rng_58 235
Anton_Lunyov 225
tourist 190
Silence 180
cedricl2 175
cgy4ever 175
DrKorbin 165
Koen 155
bbbasic 150
lunae_2 150
Submissions
Problem 1
10 pt
not submitted
98
submissions

19
correct (19 %)



25 pt
not submitted
2
submissions

1
correct (50 %)


Problem 2
5 pt
not submitted
95
submissions

38
correct (40 %)



10 pt
not submitted
19
submissions

15
correct (78 %)


Problem 3
5 pt
not submitted
153
submissions

117
correct (76 %)



15 pt
not submitted
44
submissions

25
correct (56 %)


Problem 4
10 pt
not submitted
152
submissions

54
correct (35 %)



15 pt
not submitted
23
submissions

10
correct (43 %)


Problem 5
10 pt
not submitted
36
submissions

28
correct (77 %)



20 pt
not submitted
6
submissions

2
correct (33 %)


Problem 6
5 pt
not submitted
41
submissions

29
correct (70 %)



10 pt
not submitted
15
submissions

14
correct (93 %)


Problem 7
5 pt
not submitted
38
submissions

17
correct (44 %)



10 pt
not submitted
16
submissions

15
correct (93 %)


Problem 8
5 pt
not submitted
127
submissions

104
correct (81 %)



15 pt
not submitted
47
submissions

34
correct (72 %)


Problem 9
5 pt
not submitted
86
submissions

35
correct (40 %)



15 pt
not submitted
16
submissions

15
correct (93 %)


Problem 10
5 pt
not submitted
45
submissions

23
correct (51 %)



15 pt
not submitted
15
submissions

14
correct (93 %)


Problem 11
5 pt
not submitted
81
submissions

27
correct (33 %)



15 pt
not submitted
8
submissions

3
correct (37 %)


Problem 12
5 pt
not submitted
104
submissions

88
correct (84 %)



10 pt
not submitted
31
submissions

21
correct (67 %)