【Codeforces 644A】Parliament of Berland
【链接】 我是链接,点我呀:)
【题意】
题意
【题解】
https://blog.csdn.net/V5ZSQ/article/details/70873661
看这个人的吧。
【代码】
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 100;
const long long M = 15e6;
int n,a,b,ans[N+10][N+10];
int kk = 0;
int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin >> n >> a >> b;
if (n>a*b) {
cout<<-1<<endl;
return 0;
}
int cur = 0;
if (b%2==1 || a==1){
for (int i = 1;i <= a;i++)
for (int j = 1;j <= b;j++){
if (cur<n){
ans[i][j] = ++cur;
}else ans[i][j] = 0;
}
}else{
for (int i = 1;i <= a;i++){
if (i%2==1){
for (int j = 1;j <= b;j++){
if (cur<n){
ans[i][j] = ++cur;
}else ans[i][j] = 0;
}
}else{
for (int j = b;j >= 1;j--){
if (cur<n){
ans[i][j] = ++cur;
}else ans[i][j] = 0;
}
}
}
}
for (int i = 1;i <= a;i++){
for (int j = 1;j <= b;j++){
cout<<ans[i][j]<<" ";
}
cout<<endl;
}
return 0;
}
【Codeforces 644A】Parliament of Berland的更多相关文章
- 【29.70%】【codeforces 723D】Lakes in Berland
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【Codeforces 25C】Roads in Berland
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 用floyd思想. 求出来这条新加的边影响到的点对即可. 然后尝试更新点对之间的最短路就好. 更新之后把差值从答案里面减掉. [代码] #in ...
- 【Codeforces 723D】Lakes in Berland (dfs)
海洋包围的小岛,岛内的有湖,'.'代表水,'*'代表陆地,给出的n*m的地图里至少有k个湖,求填掉面积尽量少的水,使得湖的数量正好为k. dfs找出所有水联通块,判断一下是否是湖(海水区非湖).将湖按 ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【55.70%】【codeforces 557A】Ilya and Diplomas
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 758A】Holiday Of Equality
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【16.23%】【codeforces 586C】Gennady the Dentist
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 762B】USB vs. PS/2
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【30.43%】【codeforces 746C】Tram
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
随机推荐
- 【148】DevExpress相关控件使用
---------------------------------------------------------------------------------------------------- ...
- node.js开发错误——DeprecationWarning: Mongoose: mpromise
原文地址 使用mongoose进行数据库操作时,总是提示: (node:5684) DeprecationWarning: Mongoose: mpromise (mongoose's default ...
- bzoj 1700: [Usaco2007 Jan]Problem Solving 解题【dp】
很像贪心的dp啊 这个定金尾款的设定让我想起了lolita和jk制服的尾款地狱-- 设f[i][j]为从j到i的付定金的最早月份然后从f[k][j-1]转移来,两种转移f[i][j]=min(f[i] ...
- 【js】JavaScript parser实现浅析
最近笔者的团队迁移了webpack2,在迁移过程中,笔者发现webpack2中有相当多的兼容代码,虽然外界有很多声音一直在质疑作者为什么要破坏性更新,其实大家也都知道webpack1那种过于“灵活”的 ...
- 构造 Codeforces Round #Pi (Div. 2) B. Berland National Library
题目传送门 /* 题意:给出一系列读者出行的记录,+表示一个读者进入,-表示一个读者离开,可能之前已经有读者在图书馆 构造:now记录当前图书馆人数,sz记录最小的容量,in数组标记进去的读者,分情况 ...
- Using 10053 Trace Events and get outline
When it comes to performance tuning, we can spend time on one or both ends of the problem. On the &q ...
- 中国移动Lumia机强制升级Windows10手机开发者预览版的方法
[最新消息4-9]微软已经确定将于PST太平洋标准时间周五上午十点也就是北京时间本周六(4-11)凌晨一点推送更新Windows10手机预览版 但是推送更新的机型不包括Lumia Icon 和930 ...
- myeclipse中部署svn
一.下载SVN插件subclipse 下载地址:http://subclipse.tigris.org/servlets/ProjectDocumentList?folderID=2240 在打开的网 ...
- 2017-11-28 Html-浅谈如何正确给table加边框
一般来说,给表格加边框都会出现不同的问题,以下是给表格加边框后展现比较好的方式 <style> table,table tr th, table tr td { border:1px so ...
- Visual Studio TFS
Overview:Active Directory环境下搭建TFS(一个domain内,with Domain Controller): 1)最简单的环境(这俩拓扑是从TFSAdmin文档中截取的,从 ...