zoukankan      html  css  js  c++  java
  • codeforces 459C Pashmak and Buses(模拟,组合数A)

    题目

    跑个案例看看结果就知道了:8 2 3

    题目给的数据是 n,k,d

    相当于高中数学题:k个人中选择d个人排成一列,有多少种不同的方案数,列出其中n中就可以了。

    #include<iostream>
    #include<algorithm>
    #include<string>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <math.h>
    using namespace std;
    #define ll __int64
    int mp[1005][1005];
    
    int main(){
        int n,k,d;
        scanf("%d%d%d",&n,&k,&d);
        
        int ddd=d,kkk=1;
    
        int flag=0;
        while(ddd--)
        {
            kkk=kkk*k;
            if(kkk>=n)flag=1;
        }
    
        if(flag==0)
            printf("-1
    ");
        else {
    
            int kk,num=1,kkk=1;
            for(int i=0;i<d;i++)
            {
                kk=1;
                for(int j=0;j<n;j++)
                {
                    mp[i][j]=kk;
                    if(num==kkk)kk++,kkk=0;
                    kkk++;
                    if(kk>k)kk=kk-k;
                }
                num=num*k;
            }
    
            for(int i=0;i<d;i++)
            {
                int yi=0;
                for(int j=0;j<n;j++)
                {
                    if(yi)printf(" ");yi=1;
                    printf("%d",mp[i][j]);
                }
                puts("");
            }
        }
        return 0;
    }
    View Code
  • 相关阅读:
    第一次结对作业
    第一次博客作业
    个人总结
    第三次个人作业
    第二次结对作业
    第一次结对作业
    第一次个人编程作业
    第一次博客作业
    第三次个人作业——用例图设计
    第二次结对作业
  • 原文地址:https://www.cnblogs.com/laiba2004/p/3916392.html
Copyright © 2011-2022 走看看