歌单那道题

#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的情况,不懂问题在哪里,谁能帮我看一下

全部评论
BigInteger AC
点赞 回复 分享
发布于 2018-08-31 22:16
dp无脑。。
点赞 回复 分享
发布于 2018-08-31 22:07
我只做了k<a,b的情况就30%了
点赞 回复 分享
发布于 2018-08-31 22:02
用杨辉三角解
点赞 回复 分享
发布于 2018-08-31 21:54
凡是int都不能全部ac
点赞 回复 分享
发布于 2018-08-31 21:46
70%,long long
点赞 回复 分享
发布于 2018-08-31 21:44
40%-50%徘徊
点赞 回复 分享
发布于 2018-08-31 21:37
一直30% ***了
点赞 回复 分享
发布于 2018-08-31 21:36
60 ,61行忽略掉
点赞 回复 分享
发布于 2018-08-31 21:34

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务