题目

跑个案例看看结果就知道了: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[][]; int main(){
int n,k,d;
scanf("%d%d%d",&n,&k,&d); int ddd=d,kkk=; int flag=;
while(ddd--)
{
kkk=kkk*k;
if(kkk>=n)flag=;
} if(flag==)
printf("-1\n");
else { int kk,num=,kkk=;
for(int i=;i<d;i++)
{
kk=;
for(int j=;j<n;j++)
{
mp[i][j]=kk;
if(num==kkk)kk++,kkk=;
kkk++;
if(kk>k)kk=kk-k;
}
num=num*k;
} for(int i=;i<d;i++)
{
int yi=;
for(int j=;j<n;j++)
{
if(yi)printf(" ");yi=;
printf("%d",mp[i][j]);
}
puts("");
}
}
return ;
}

codeforces 459C Pashmak and Buses(模拟,组合数A)的更多相关文章

  1. CodeForces - 459C - Pashmak and Buses

    先上题目+: C. Pashmak and Buses time limit per test 1 second memory limit per test 256 megabytes input s ...

  2. codeforces 459C Pashmak and Buses 解题报告

    题目链接:http://codeforces.com/problemset/problem/459/C 题目意思:有 n 个 students,k 辆 buses.问是否能对 n 个students安 ...

  3. CodeForces 459C Pashmak and Buses(构造)题解

    题意:n个人,k辆车,要求d天内任意两人都不能一直在同一辆车,能做到给出构造,不能输出-1 思路:我们把某一个人这d天的车号看成一个d位的数字,比如 1 1 2 3代表第一天1号车.第二天1号车.第三 ...

  4. Codeforces 459C Pashmak and Buses 机智数学题

    这个题目说的是有n个人,有k辆巴士,有m天,每天都要安排n个人坐巴士(可以有巴士为空),为了使得这n个人不会成为朋友,只要每两个人在这m天里坐的巴士至少一天不相同即可. 要你求是否有这样的安排方法,如 ...

  5. cf 459c Pashmak and Buses

    E - Pashmak and Buses Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I ...

  6. codeforces #261 C题 Pashmak and Buses(瞎搞)

    题目地址:http://codeforces.com/contest/459/problem/C C. Pashmak and Buses time limit per test 1 second m ...

  7. CF459C Pashmak and Buses (构造d位k进制数

    C - Pashmak and Buses Codeforces Round #261 (Div. 2) C. Pashmak and Buses time limit per test 1 seco ...

  8. cf459C Pashmak and Buses

    C. Pashmak and Buses time limit per test 1 second memory limit per test 256 megabytes input standard ...

  9. codeforces 459D - Pashmak and Parmida&#39;s problem【离散化+处理+逆序对】

    题目:codeforces 459D - Pashmak and Parmida's problem 题意:给出n个数ai.然后定义f(l, r, x) 为ak = x,且l<=k<=r, ...

随机推荐

  1. 【设计模式】策略模式 (Strategy Pattern)

    策略模式是一种很简单的基础模式,用于封装一系列算法,使客户端的访问独立于算法的实现.我们可以”井中取水”来形象的描述策略模式.“取水”是一个动作,完成这个动作的方式有很多中,可以直接用手提.可以用水车 ...

  2. MongoDB复制机制实例

    MongoDB的主从复制是一个主可以多从已从又可以为主进行主从复制.在这里就是实现一主一从一个仲裁服务器使用一个数据库服务器通过提供不同的端口. 一.启动一个MongoDB服务名字是applicati ...

  3. spring AOP advice 类型 和 通用的切点的配置方式

    spring aop advice的类型: 1.前置通知(before advice) 2.返回后通知(after returning advice) 3.抛出异常后通知(after throwing ...

  4. TextSwitcher,译为文字转换器控件

    ViewSwitcher仅仅包含子类型TextView.TextSwitcher被用来使屏幕上的label产生动画效果.每当setText(CharSequence)被调用时,TextSwitcher ...

  5. OpenStack:初识

    OpenStack提纲:-------------------------------------------初识OpenStack, 千头万绪, 不知所措. 逐渐剥茧抽丝, 厘清思路...一. Op ...

  6. mysql 创建一个用户,指定一个数据库

    mysql 创建一个用户 hail,密码 hail,指定一个数据库 haildb 给 hail mysql -u root -p password use mysql; insert into use ...

  7. webpack对样式的处理

    原文地址:https://github.com/zhengweikeng/blog/issues/9 我们可以在js中引入样式文件 require('myStyle.css') 这时我们便需要引入相应 ...

  8. 【每日scrum】NO.5

    尝试采用自己的地图,绘点并计算路径,但是地图打开出现问题.

  9. UITableView的常用属性和cell的内存优化

    UITableView的常用属性: 分割线颜色设置: 1> 设置separatorStyle: 分割线的颜色 方法:tableView.separatorStyle = UITableViewC ...

  10. asp.net页面的请求处理响应的过程描述

    概述 本篇博客从IIS到asp.net页面后台运行完,整个过程做一个简单的描述,如果有不对的地方,望指出. IIS处理请求的过程 我们通过浏览器(Socket客户端)访问一个IIS服务器上的网页时,该 ...