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

【题意】

题意

【题解】

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. MySQL 操作语句

    解释:|:或;{}:必选;[]:可选 创建数据库并指定字符编码: CREATE {DATABASE|SCHEMA} [IF NOT EXISTS] db_name [DEFAULT] CHARACTE ...

  2. mybatis编写mapper操作

    mybatis编写mapper resultType和resultMap resultType可以直接指定返回类型,例如自定义的bean  <!--通过账号查询用户:一个参数用parameter ...

  3. 题解报告:poj 2386 Lake Counting(dfs求最大连通块的个数)

    Description Due to recent rains, water has pooled in various places in Farmer John's field, which is ...

  4. LN : leetcode 53 Maximum Subarray

    lc 53 Maximum Subarray 53 Maximum Subarray Find the contiguous subarray within an array (containing ...

  5. LN : leetcode 258 Add Digits

    lc 258 Add Digits lc 258 Add Digits Given a non-negative integer num, repeatedly add all its digits ...

  6. ADPU 大全

    APDU协议 APDU协议,即是智能卡与读写器间的应用层协议,在ISO7816-4[7]中定义了该协议的结构格式.APDU数据有两种结构,读写器使用的APDU结构为命令APDU,C-APDU(Comm ...

  7. oracle数据库定时备份

    现有需求,设计一批处理文件,实现周一全部备份,周二周三周五周六增量备份,周四周日累计备份.并且每日将上个月本日数据删除(如今日8月7号,则删除7月7号的数据).并将备份压缩以减小所占空间. 思路: 备 ...

  8. Clickhouse DDL&DML

    (1)添加列: alter table [db.]table_name add column column_name [type] [default_expr] [after name_after] ...

  9. 大数除法(除数在int范围内)

    #include<iostream> #include<cstdio> #include<cstring> #define N 1000 using namespa ...

  10. 模式匹配第四弹:if case,guard case,for case

    2016-06-06 7388 作者:Olivier Halligon,原文链接,原文日期:2016-05-16 译者:walkingway:校对:Cee:定稿:numbbbbb 现在我们来重新回顾下 ...