【链接】 我是链接,点我呀:)

【题意】

题意

【题解】

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的更多相关文章

  1. 【29.70%】【codeforces 723D】Lakes in Berland

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  2. 【Codeforces 25C】Roads in Berland

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 用floyd思想. 求出来这条新加的边影响到的点对即可. 然后尝试更新点对之间的最短路就好. 更新之后把差值从答案里面减掉. [代码] #in ...

  3. 【Codeforces 723D】Lakes in Berland (dfs)

    海洋包围的小岛,岛内的有湖,'.'代表水,'*'代表陆地,给出的n*m的地图里至少有k个湖,求填掉面积尽量少的水,使得湖的数量正好为k. dfs找出所有水联通块,判断一下是否是湖(海水区非湖).将湖按 ...

  4. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  5. 【55.70%】【codeforces 557A】Ilya and Diplomas

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  6. 【codeforces 758A】Holiday Of Equality

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. 【16.23%】【codeforces 586C】Gennady the Dentist

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. 【codeforces 762B】USB vs. PS/2

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  9. 【30.43%】【codeforces 746C】Tram

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

随机推荐

  1. 0626-TP整理二(调试模式,空操作,跨控制器调用,跨方法跳转--redirect(),框架语法,创建model模型)

    一.调试模式(入口文件:index.php) define('APP_DEBUG', true);  //调试模式 define('APP_DEBUG', FALSE);  //运行模式 开启日志信息 ...

  2. 开车旅行 2012年NOIP全国联赛提高组(倍增+set)

    开车旅行 2012年NOIP全国联赛提高组  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond     题目描述 Description 小A 和小B决定利用 ...

  3. python如何添加浏览器驱动路径

    闲来无事,整一整python+selenium,写完代码后运行发现找不到webdriver的路径:之前是仿照java一样直接把webdriver放到浏览器的安装目录下 迫于无奈,只好查一下问题如何处理 ...

  4. TCP/IP 3握手4挥手

    转:摘自<图解TCP/IP>P204 三次握手与四次挥手的状态转移图如下: 如图,由于第二次握手接收端发送SYN+ACK信号所以握手只用了三次,挥手由于接收端ACK和FIN分两次发的,所以 ...

  5. 238 Product of Array Except Self 除自身以外数组的乘积

    一个长度为 n 的整形数组nums,其中 n > 1,返回一个数组 output ,其中 output[i] 等于nums中除nums[i]以外所有元素的乘积.不用除法 且在O(n)内解决这个问 ...

  6. java 利用Xstream注解生成和解析xml

    https://www.oschina.net/code/snippet_116183_14202#23325

  7. vue-devtools是vue浏览器调试工具

    开vue官网在vue-生态系统-工具可以看到vue-devtools这个工具: vue-devtools是一款基于chrome游览器的插件,用于调试vue应用,这可以极大地提高我们的调试效率.接下来我 ...

  8. Android Studio Activity Intent 闪退崩溃 Toolbar

    今天写登录注册页面,点击登录页面的“注册”按钮后软件突然崩溃,直接闪退,因为是新手,只能去网上搜.虽然网上解决方法众多,但也没找到可行的.想起来可以看Logcat,马上重新运行应用,查看崩溃时的日志, ...

  9. AdMob设计工具google web designer

    一.google web designer工具中文文档: https://support.google.com/webdesigner?hl=zh-Hans#topic=3227692 我用的版本:应 ...

  10. CAD使用GetxDataLong读数据(网页版)

    主要用到函数说明: MxDrawEntity::GetxDataLong2 读取一个Long扩展数据,详细说明如下: 参数 说明 [in] LONG lItem 该值所在位置 [out, retval ...