Pashmak and Buses(构造)
题目链接:http://codeforces.com/problemset/problem/459/C
题意:n个人, k辆车, d天,每天将所有 任意人安排到k辆车, 问怎样安排, 可时不存在 2人或2人以上 d天都在一起。
题解:可以构造一个数组A, n行d列,0<a[i][j] <= k. 不存在两行完全相等,由此可得 k^d < n 可以构造以个k进制数, 从0 加到n
不得不说智商是硬伤T T,看了赛后题解才恍然大悟。
/***Good Luck***/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <functional>
#include <cmath> #define Zero(a) memset(a, 0, sizeof(a))
#define Neg(a) memset(a, -1, sizeof(a))
#define All(a) a.begin(), a.end()
#define PB push_back
#define inf 0x3f3f3f3f
#define inf2 0x7fffffffffffffff
#define ll long long
using namespace std;
//#pragma comment(linker, "/STACK:102400000,102400000")
void get_val(int &a) {
int value = , s = ;
char c;
while ((c = getchar()) == ' ' || c == '\n');
if (c == '-') s = -s; else value = c - ;
while ((c = getchar()) >= '' && c <= '')
value = value * + c - ;
a = s * value;
}
const int maxn = ;
int ret[maxn][maxn];
int n, k, d; int main() {
//freopen("data.out", "w", stdout);
//freopen("data.in", "r", stdin);
//cin.sync_with_stdio(false);
cin >> n >> k >> d;
bool flag = false;
int tmp = ;
for (int i = ; i <= d; ++i)
if (tmp < n) tmp *= k;
else {
flag = true;
break;
}
if (!flag) {
cout << - << endl;
return ;
}
int jz = ;
for (int i = ; i <= n; ++i) {
jz = ;
for (int j = ; j <= d; ++j) {
ret[i][j] = (ret[i - ][j] + jz) % k;
if (ret[i][j] < ret[i - ][j]) jz = ;
else jz = ;
}
}
for (int i = ; i <= d; ++i) {
for (int j = ; j < n; ++j) {
printf("%d ", ret[j][i] + );
}
printf("%d\n", ret[n][i] + );
}
return ;
}
Pashmak and Buses(构造)的更多相关文章
- 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 #261 C题 Pashmak and Buses(瞎搞)
题目地址:http://codeforces.com/contest/459/problem/C C. Pashmak and Buses time limit per test 1 second m ...
- cf 459c Pashmak and Buses
E - Pashmak and Buses Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I ...
- 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(构造)题解
题意:n个人,k辆车,要求d天内任意两人都不能一直在同一辆车,能做到给出构造,不能输出-1 思路:我们把某一个人这d天的车号看成一个d位的数字,比如 1 1 2 3代表第一天1号车.第二天1号车.第三 ...
- codeforces 459C Pashmak and Buses 解题报告
题目链接:http://codeforces.com/problemset/problem/459/C 题目意思:有 n 个 students,k 辆 buses.问是否能对 n 个students安 ...
- codeforce Pashmak and Buses(dfs枚举)
/* 题意:n个同学,k个车, 取旅游d天! 要求所有的学生没有两个或者两个以上的在同一辆车上共同带d天! 输出可行的方案! 对于d行n列的矩阵,第i行第j列表示的是第i天第j个同学所在的车号! 也就 ...
- codeforces 459C Pashmak and Buses(模拟,组合数A)
题目 跑个案例看看结果就知道了:8 2 3 题目给的数据是 n,k,d 相当于高中数学题:k个人中选择d个人排成一列,有多少种不同的方案数,列出其中n中就可以了. #include<iostre ...
随机推荐
- Linux::mysql-connector-c++
.安装好boost. .从官网下载mysql connector c++版本. .解压,复制 include/jdbc/cppconn 文件夹复制,到/usr/local/include/cppcon ...
- L2-007. 家庭房产(并查集)
#include <cstdio> #include <set> #include <vector> #include <algorithm> usin ...
- 第三方软件 vnc提权
通过读取注册表十进制数 将得出的十进制数去掉第一个数其他转换成16进制 破解16进制数得到密码 vncx.exe -W 回车 输入16进制数 连接vnc 读取 vncx4.exe -w 8个数 自动破 ...
- linux+jenkins+github+python持续集成
1.服务器上事先安装jenkins 参见:linux上war包方式安装Jenkins 2.新建一个自由风格的job,名字随意起 3.配置git(拉取github代码) 从github复制pytho ...
- spring cloud(Greenwich SR)- Eureka
spring cloud study 本次学习基于spring cloud Greenwich SR1 版本 学习要点: Spring Boot/Spring Cloud应用开发套路 加依赖 加注解 ...
- The usage of Markdown---代码块
目录 1. 序言 2. 代码块 3. 引用中的代码 4. 列表中的代码块 更新时间:2019.09.14 1. 序言 在写技术博客的时候,我们常常需要添加一下代码块用来做演示说明,实际上在这篇博客 ...
- 设计模式C++描述----08.原型(Prototype)模式
一. 概述 定义:用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象. 换句话说,就是不用重新初始化对象,而是动态地获得对象运行时的状态. 再说明白点,就是要一个拷贝过构造函数类似功能的接 ...
- 【MySQL】MySQL服务启动失解决方法
写在前面的话:前段时间,为了更加流畅愉快的玩PUBG,我在任务管理器中,关闭了mysqld服务.后来我在使用MySQL数据库服务的时候,发现去到MySQL安装目录下双击运行mysqld.exe(数据库 ...
- if __name__ == "__main__" 的作用
作用:当模块被直接运行时,以下代码块将被运行,当模块是被导入时,代码块不被运行. 例子: # file one.py def func(): print("func() in one.py& ...
- Pandas常用数据结构
Pandas 概述 Pandas(Python Data Analysis Library)是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的.Pandas 纳入了大量库和一些标准的数 ...