博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CodeForces 459C(构造题)
阅读量:4286 次
发布时间:2019-05-27

本文共 906 字,大约阅读时间需要 3 分钟。

   

/**题意:有n个同学,k辆车,d天(每天n个同学去一个地方)    问经过d天后,任意的多个同学不能总在一起d天里,每天怎样分配车辆题解:一个构造题,求0 ~ n的k进制下的数 + 1;    注: n > k ^ d 则不能构造**/#include
#include
#include
#include
#include
using namespace std;int a[1005][1005];int main(){ int n,k,d; while(cin >> n >> k >> d){ if(double(n) > pow((double)k,d)) cout << -1 << endl; else { memset(a,0,sizeof(a)); for(int S = 0;S < n;S++) { int tmp = S,j = 0; for(int j = 0;tmp;j++) { a[j][S] = tmp % k; tmp /= k; } } for(int i = 0;i < d;i++){ for(int S = 0;S < n - 1;S++){ cout << a[i][S] + 1 << " "; } cout << a[i][n-1] + 1 << endl; } } } return 0;}

转载地址:http://rcsgi.baihongyu.com/

你可能感兴趣的文章
EntityFramework中Json序列化的循环引用问题解决--Newtonsoft.Json
查看>>
AngularJs----ng-class
查看>>
Bootstrap3 datetimepicker控件的使用
查看>>
NodeJs常用链接整理
查看>>
Bootstrap model的使用及点击外部不消失
查看>>
Linq To Entity多条件or查询处理
查看>>
AngularJs ng-options
查看>>
Jquery Md5加密-Jquery.md5.js
查看>>
JQuery.cookie.js操作客户端cookie
查看>>
Git官网下载windows版本慢的问题
查看>>
Js 取模运算、取商、取整方法
查看>>
NodeJs开发环境之Sublime Text3
查看>>
Sublime text 2/3 [Decode error - output not utf-8] 完美解决方法
查看>>
ffmpeg ffplay ffprobe资料整理
查看>>
Sublime Text 插件之Emmet
查看>>
SublimeText插件之CodeFormatter
查看>>
Node.Js 全局对象与全局属性(一)
查看>>
Node.Js Path模块-文件或文件夹路径字符串操作
查看>>
Node.Js fs模块文件夹操作
查看>>
Bootstrap 弹出框modal上层的输入框不能获得焦点问题
查看>>