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 ...
随机推荐
- 14.Nginx四层负载均衡
1.七层负载均衡: 根据url 调度不同的集群 url.cheng.com 10.0.0.5 10.0.0.7 /pass 10.0.0.8 /user 1.web01和web02配置 (只不过代码不 ...
- Linux系统 /etc目录下主要配置文件解释
这些都是比较有实用性的系统配置,收藏下,以备不时之需!以下是etc下重要配置文件解释: 1./etc/hosts #文件格式: IPaddress hostname aliases #文件功能: 提 ...
- Leetcode Tags(6)Math
一.204. Count Primes Count the number of prime numbers less than a non-negative number, n. Input: 10 ...
- Android应用程序版本升级时签名冲突
这种错误特别容易在调试中出现,原因是你手机上的应用是直接用eclipse或者android studio安装的,而eclipse或者android studio有自己默认的签名:**debug.key ...
- JAVA基础知识注意事项
JAVA核心技术卷一 (第十版) 下面是需要注意的: 只有方法名和参数类型叫做方法的签名, 不同的返回类型值不能作为方法的签名.(4.6.1) 这是域与局部变量的主要不同点. 必须明确地初始化方法中的 ...
- Alpha阶段--第六周Scrum Meeting
任务内容 本次会议为第六周的Scrum Meeting会议 召开时间为周四上午10点,在信南B317召开,召开时间约为30分钟,进行的项目规划和分工 队员 任务 张孟宇 进行用户登录界面的代码编写 吴 ...
- 使用Java调用exe可执行文件
一.出发点 平日里,我们看到了很多已经成型的可执行文件,而且经过了一定的封装.因为开源的关系,大多时候可以自己使用eclipse进行编译,但也常常遇到不如直接调用更加方便的情况.那么这时候,我个人需要 ...
- 【BZOJ4720】【UOJ262】【NOIP2016】换教室
Description 对于刚上大学的牛牛来说,他面临的第一个问题是如何根据实际情况申请合适的课程. 在可以选择的课程中,有 2n 节课程安排在n个时间段上.在第 i(1≤i≤n)个时间段上,两节内容 ...
- [考试反思]1013csp-s模拟测试72:距离
最近总是这个样子. 看上去排名好像还可以,但是实际上离上面的分差往往能到80分,但是身后的分差其实只有10/20分. 比上不足,比下也不怎么的. 所以虽然看起来没有出rank10,但是在总分排行榜上却 ...
- Hive数据仓库你了解了吗
在工作中我们经常使用的数据库,数据库一般存放的我们系统中常用的数据,一般为百万级别.如果数据量庞大,达到千万级.亿级又需要对他们进行关联运算,该怎么办呢? 前面我们已经介绍了HDFS和MapReduc ...