【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 ...
随机推荐
- GitHub上README.md教程(copy)
[说明:转载于http://blog.csdn.net/kaitiren/article/details/38513715] 最近对它的README.md文件颇为感兴趣.便写下这贴,帮助更多的还不会编 ...
- Same Tree 序列化二叉树
https://oj.leetcode.com/problems/same-tree/ Given two binary trees, write a function to check if the ...
- 【js】JavaScript parser实现浅析
最近笔者的团队迁移了webpack2,在迁移过程中,笔者发现webpack2中有相当多的兼容代码,虽然外界有很多声音一直在质疑作者为什么要破坏性更新,其实大家也都知道webpack1那种过于“灵活”的 ...
- Hbase源码分析:RPC概况
RPC是hbase中Master,RegionServer和Client三者之间通信交流的纽带.了解hbase的rpc机制能够为通过源码学习hbase奠定良好的基础.因为了解了hbase的rpc机制能 ...
- 设置打印机共享,适用Win7、Vista、xp,不用密码
此处以HP M1213nf为例,其他型号大同小异. 1.设置打印机共享: "开始"→ "控制面板"→ "设备和打印机" 2.找到&quo ...
- 跨站脚本攻击XXS(Cross Site Scripting)修复方案
今天突然发现,网站被主页莫名奇妙的出现了陌生的广告. 通过排查发现是跨站脚本攻击XXS(Cross Site Scripting).以下为解决方案. 漏洞类型: Cross Site Scriptin ...
- Solr搜索引擎 — 通过mysql配置数据源
一,准备数据库数据表结构 CREATE TABLE `app` ( `id` int(11) NOT NULL AUTO_INCREMENT, `app_name` varchar(255) NOT ...
- JavaScipt30(第十个案例)(主要知识点:选中一个数组中间相连部分进行操作的一种思路)
承接上文,第九个案例就不说了,是控制台的一些东西,一般用的很少,了解下就行了,想用的时候再翻api.这是第10个案例: 需要实现的效果是:点击一个checkbox,然后按下shift点击另一个chec ...
- 01Hypertext Preprocessor
Hypertext Preprocessor PHP即Hypertext Preprocessor是一种被广泛使用的开放源代码多用途动态交互性站点的强有力的服务器端脚本语言尤其适用于 Web开发人员可 ...
- Java变量及数据类型
变量及数据类型 变量 变量定义格式:数据类型 变量名 = 初始化值; 基本数据类型 整形数据 package com.ahabest.demo; //输出整形数据的最小值,默认值,最大值,二进制位数 ...