【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 ...
随机推荐
- UVaLive 6832 Bit String Reordering (模拟)
题意:给定一个01序列,然后让你你最少的操作数把这它变成目标. 析:由于01必须是交替出现的,那么我们就算两次,然后取最值. 代码如下: #pragma comment(linker, "/ ...
- canvas particles
var canvas = document.getElementById('canvas'); var ctx = canvas.getContext('2d'); var Grewer = { in ...
- c++编程中处理char和wchar_t的好工具
/* ttype.h sdragonx 2015-02-18 18:32:43 这个几个模版函数是为了处理ansi或unicode,使字符串值或者字符串函数能够在模版中使用 2018/7/26 23: ...
- Maven之项目搭建与第一个helloworld(多图)
这次记录第一个搭建一个maven的helloworld的过程. 转载 1.搭建web工程肯定得new 一个 maven工程,假如project中没有直接看到maven工程,那么选择Other,然后在W ...
- BFS POJ 3126 Prime Path
题目传送门 /* 题意:从一个数到另外一个数,每次改变一个数字,且每次是素数 BFS:先预处理1000到9999的素数,简单BFS一下.我没输出Impossible都AC,数据有点弱 */ /**** ...
- hihocoder #1698 假期计划 (排列组合+费马小定理+乘法逆元)
Description 小Ho未来有一个为期N天的假期,他计划在假期中看A部电影,刷B道编程题.为了劳逸结合,他决定先拿出若干天看电影,再拿出若干天刷题,最后再留若干天看电影.(若干代指大于0) 每 ...
- poj2289 Jamie's Contact Groups
思路: 二分+最大流.实现: #include <stdio.h> #include <stdlib.h> #include <limits.h> #include ...
- Android基础夯实--重温动画(一)之Tween Animation
心灵鸡汤:真正成功的人生,不在于成就的大小,而在于你是否努力地去实现自我,喊出自己的声音,走出属于自己的道路. 摘要 不积跬步,无以至千里:不积小流,无以成江海.学习任何东西我们都离不开扎实的基础知识 ...
- LR接口测试---基于http协议之get/post
get请求代码: //=====================get interface======================== 以http状态码方式: //获取返回的HTTP状态码判断请求 ...
- ElasticSearch 安装使用
安装: 1.下载ElasticSearch.解压到相关文件夹 2.运行elasticsearch.bat,启动程序 3.在浏览器输入:http://localhost:9200/,显示相关Es内容即安 ...