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[][]; 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)的更多相关文章
- CodeForces - 459C - Pashmak and Buses
先上题目+: C. Pashmak and Buses time limit per test 1 second memory limit per test 256 megabytes input s ...
- codeforces 459C Pashmak and Buses 解题报告
题目链接:http://codeforces.com/problemset/problem/459/C 题目意思:有 n 个 students,k 辆 buses.问是否能对 n 个students安 ...
- CodeForces 459C Pashmak and Buses(构造)题解
题意:n个人,k辆车,要求d天内任意两人都不能一直在同一辆车,能做到给出构造,不能输出-1 思路:我们把某一个人这d天的车号看成一个d位的数字,比如 1 1 2 3代表第一天1号车.第二天1号车.第三 ...
- Codeforces 459C Pashmak and Buses 机智数学题
这个题目说的是有n个人,有k辆巴士,有m天,每天都要安排n个人坐巴士(可以有巴士为空),为了使得这n个人不会成为朋友,只要每两个人在这m天里坐的巴士至少一天不相同即可. 要你求是否有这样的安排方法,如 ...
- cf 459c Pashmak and Buses
E - Pashmak and Buses Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I ...
- codeforces #261 C题 Pashmak and Buses(瞎搞)
题目地址:http://codeforces.com/contest/459/problem/C C. Pashmak and Buses time limit per test 1 second m ...
- 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 ...
- cf459C Pashmak and Buses
C. Pashmak and Buses time limit per test 1 second memory limit per test 256 megabytes input standard ...
- codeforces 459D - Pashmak and Parmida's problem【离散化+处理+逆序对】
题目:codeforces 459D - Pashmak and Parmida's problem 题意:给出n个数ai.然后定义f(l, r, x) 为ak = x,且l<=k<=r, ...
随机推荐
- Ubuntu无值守安装mysql
1. 使用apt-get -d install 命令下载安装包, 其中-d表示下载不安装. 下载后的deb包放在/var/cache/apt/archives目录 2. 使用dpkg-preconfi ...
- 先登陆面试再者Tabs标签导航,多次网络请求共享cookie,本地存储cookie
1,index.ng.html: <head> <title>ionic todo example</title> </head> <body n ...
- dede 忘记密码在数据库中修改方法
如何找回或修改dedecms后台管理员登录密码呢? 一个客户把密码忘了,找了很长一会没几个靠谱的回答,dede是使用md5加密,但是,它是显示32位md5加密码从第6位开始的20位 方法是直接修改其m ...
- 修改linux端口范围 ip_local_port_range
tags: ip_local_port_range 端口范围 sysctl Linux中有限定端口的使用范围,如果我要为我的程序预留某些端口,那么我需要控制这个端口范围, 本文主要描述如何去修改端口范 ...
- MongoDB 数据类型
MongoDB支持许多数据类型的列表下面给出: String : 这是最常用的数据类型来存储数据.在MongoDB中的字符串必须是有效的UTF-8. Integer : 这种类型是用来存储一个数值.整 ...
- iOS9之Bitcode
Bitcode是被编译程序的一种中间形式的代码. 更新Xcode7后需要将”Build Settings”->”Enable Bitcode”设为NO,保证第三方库能真机运行项目. ...
- 关于ios极光推送server端注意的地方
今天试用了极光推送API 用它是因为,大多数人说它的文档是最全的,但是用过之后,发现关于IOS的文档,还是很不够,导致走了一点弯路! 特别是服务端的代码:https://github.com/jpus ...
- Objective-C 一些概念
Automatic Reference Counting (ARC)
- 可综合风格的VerilogHDL模块实例
1.赋值语句:assign{cout,sum}=a+b+cin; 2.利用电平敏感的always块设计组合逻辑电路 3.always块中如果含有局部变量,就必须在begin后加模块名,是必须加,同样的 ...
- DHCP Server软件使用教程
DHCP Server软件使用教程 前提网络环境配置 电脑连接上wifi 网络和共享中心中更改适配器,共享无线网卡给以太网网卡 手动设置以太网网卡ipv4地址为192.168.1.1,子网掩码为255 ...