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, ...
随机推荐
- WPF DragDrop事件元素跟随
前一段时间项目里面要实现一个鼠标拖动一个元素到另外一个元素上面并且赋值的功能,由于要在surface上运行,拖动的时候手指会挡住系统默认的拖动图标,导致用户意识不到自己是不是在拖动着东西,所以要解决这 ...
- LaTeX插入jpg图片: 使用graphicx
首先要包含宏包 \usepackage{graphicx} \begin{figure}[ht!] \centering \includegraphics[width=90mm]{fixed_dome ...
- 我的WPF控件库——KAN.WPF.XCtrl(141105)
自己开发的WPF控件库,只是初版,有扩展的Button,TextBox,Window.详细参见前几篇博文. WPF自定义控件(一)——Button:http://www.cnblogs.com/Qin ...
- Microsoft SqlServer2008技术内幕:T-Sql语言基础-读书笔记-单表查询SELECT语句元素
1.select语句逻辑处理顺序: FORM WHERE GROUP BY HAVING SELECT OVER DISTINCT TOP ORDER BY 总结: 2.FORM子句的表名称应该带上数 ...
- OpenStack:安装Neutron与provider network
1. 安装(1)Install Networking services on a dedicated network node# apt-get install neutron-server neut ...
- Python运行Google App Engineer时出现的UnicodeDecodeError错误解决方案
#Python运行Google App Engineer时出现的UnicodeDecodeError错误解决方案 ##问题描述 使用Python2.7.x运行GAE时有时会报这个错误 ```py ...
- sharepoint 2010 基于AD的Form验证
一.新建web应用程序 1.验证部分选择“基于声明的身份验证” 2.设置端口 3.选择“启用基于窗体的身份验证(FBA)” “ASP.NET 成员身份提供程序名称”下面填写“LdapMember” “ ...
- gameObject, vector and transform
调用其它组件中成员 通过GameObject(游戏物体). Base class for all entities in Unity scenes. 是Unity场景里面所有实体的基类. 可以理解为 ...
- strlen和mb_strlen区别
转自:http://blog.sina.com.cn/s/blog_5f0d5bd90100mzcl.html <?php//测试时文件的编码方式要是UTF8$str='中文a字1符';echo ...
- mobiscroll 控件的使用(手机端日历控件)
先上一张图吧: 控件的下载地址:http://www.kuitao8.com/20140604/2615.shtml 文档API地址:http://docs.mobiscroll.com/2-13-2 ...