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 ...
随机推荐
- vue实现跑马灯效果
vue实现跑马灯效果为阿中哥哥应援 1.效果图 2.实现代码 <!DOCTYPE html> <html lang="en"> <head> & ...
- 卡特兰(Catalan)数入门详解
也许更好的阅读体验 基本概念 介绍 学卡特兰数我觉得可能比组合数要难一点,因为组合数可以很明确的告诉你那个公式是在干什么,而卡特兰数却像是在用大量例子来解释什么时卡特兰数 这里,我对卡特兰数做一点自己 ...
- 基于MVC的RESTful风格的实现
基于MVC的RESTful风格的实现 1.RESTful风格阐述 REST服务是一种ROA(Resource-Oriented Architecture,面向资源的架构)应用.主要特点是方法信息存在于 ...
- NetworkManager网络通讯_问题汇总(四)
此篇来填坑,有些坑是unet自身问题,而大部分则是理解不准确造成的(或者unity定义太复杂) 问题一: isLocalPlayer 值一直是false 出现场景:NetworkLobbyPlayer ...
- fenby C语言 P22
#include <stdio.h> int main(){ char array[]={'t','o','m','c','a','t'}; int i; for(i=0;i<6;i ...
- 透明度设置opacity
透明度设置opacity属性 示例 <!DOCTYPE html> <html> <head> <style> div { background-col ...
- iOS开发高级分享 - iOS上的设备标识符和指纹
苹果认可的标识符 Apple提供了各种API,以方便用户识别各种用途: 通用标识符(UDID) 在iOS的早期,苹果公司提供了一个uniqueIdentifier财产上UIDevice-亲切地称为ud ...
- 解决靶机Bee-Box 键盘乱序问题
Bee-Box介绍 Bee-box官方称呼BWAPP,buggy web Application 这是一个集成了各种常见漏洞和最新漏洞的开源Web应用程序,目的是帮助网络安全爱好者.开发人员和学生发现 ...
- 转:nginx和php-fpm的两种通信方式
原文地址:https://segmentfault.com/q/1010000004854045 Nginx和PHP-FPM的进程间通信有两种方式,一种是TCP,一种是UNIX Domain Sock ...
- 入职第一天,装环境 .Ubuntu装jdk1.8,装idea 及tomcat
入职第一天,和之前公司的开发环境感觉天壤之别了,不过万变不离其宗,之前公司eclipse+widows.所以很少玩linux了.今天来就干了一件事.装环境 jdk安装. 下载地址:https://ww ...