When iam entering manually i am getting write answer

#include
using namespace std;
int main(){
int t;
cin>>t;
while(t–){
long long int n,m,ans;
ans=1;
cin>>n>>m;
n=n-1;
m=m-1;
if(n-m<m){
m=n-m;
}
int x=1;

	for(long long int  i=n;i>m;i-- ){
		
		ans=ans*(i);
		ans=ans/x;
		x++;
		
		
	}
	
	cout<<ans<<endl;
	
	
	
	
}

}

you are calculating nCm, which is not correct solution to given problem!
You must choose 1 marble of each color!, after that you may choose any configuration, (also take care of marbles with same color as this will further reduce number of ways)

i am subractracting 1 at the begining

For each color! so subtract by k(or m).// n = n-m;
and dont decrease m.
after that take (n+m)!/n!Xm! (using stars and bars method)


it is working for given test cases by getting wrong while submitting i am not understanding where the over flow is

Try this test
1
120 7, answer should be 3470108187 but your code gives 0.
don’t worry about overflow, as mod is also not given!

1 Like

actually you should decrease m by 1.(which you are doing correct!)

i got it is for(int i=n;i>n-m;i–)
thanks