歌单那道题
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
int zuhe(int a,int b){ //排列组合,a小b大
if(a==0)
return 1;
else{
int tempb=1;
int tempa=1;
for(int i=0;i<a;i++){
tempb=tempb*(b-i);
tempa=tempa*(a-i);
}
return tempb/tempa;
}
}
int cal(int a,int b, int c,int d){ //C(a,b)*C(c,d)
int temp=1;
temp=zuhe(a,b)*zuhe(c,d);
return temp;
}
int main(){
int K = 0 ;
int A = 0 , X = 0 , B = 0 , Y = 0 ;
cin >>K ;
cin >>A >>X >>B >>Y ;
int sum=0;
int temp=0;
int X_num=0,Y_num=0;
if(A==0&&B==0)
sum= 0;
else if(A==0){
Y_num=K/B;
if(K%B==0&&Y_num<=Y)
sum=zuhe(Y_num,Y);
}
else if(B==0){
X_num=K/A;
if(K%A==0&&X_num<=X)
sum=zuhe(X_num,X);
}
else{
for(X_num=0;X_num<=X;X_num++){
temp=K-X_num*A;
if(temp<0)
break;
Y_num=temp/B;
if(temp%B==0&&Y_num<=Y){
sum=(sum+cal(X_num,X,Y_num,Y))%1000000007;
}
}
}
cout << sum ;
int test=zuhe(3,3);
cout<<test;
return 0;
}
说句实话很难受,一直是60%,说我遇到了除数为0的情况,不懂问题在哪里,谁能帮我看一下