地址 Problem - C - Codeforces

题意

每个格子,该格子和相邻的格子的值不能相同

题解

思维题, 先从1~n输出奇数,再输出偶数

代码

#include <iostream>
#include <string>
#include <algorithm> using namespace std; typedef long long LL; int a[110][110]; int main()
{
LL n, t;
cin >> t;
while(t --)
{
cin >> n;
if(n == 2)
{
puts("-1");
continue;
}
int step = -1;
for(int i = 1; i <= n; i ++)
{
for(int j = 1; j <= n; j ++)
{
step += 2;
if(step > n*n) step = 2;
cout << step << ' ';
}
puts("");
}
}
return 0;
}

Codeforces Round #719 (Div. 3) C. Not Adjacent Matrix的更多相关文章

  1. 刷题记录:Codeforces Round #719 (Div. 3)

    Codeforces Round #719 (Div. 3) 20210703.网址:https://codeforces.com/contest/1520. 没错,我是个做div3的蒟蒻-- A 大 ...

  2. Codeforces Round #277 (Div. 2) B. OR in Matrix 贪心

    B. OR in Matrix Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/486/probl ...

  3. Codeforces Round #495 (Div. 2) D. Sonya and Matrix

    http://codeforces.com/contest/1004/problem/D 题意: 在n×m的方格中,选定一个点(x,y)作为中心点,该点的值为0,其余点的值为点到中心点的曼哈顿距离. ...

  4. Codeforces Round #524 (Div. 2) E. Sonya and Matrix Beauty(字符串哈希,马拉车)

    https://codeforces.com/contest/1080/problem/E 题意 有一个n*m(<=250)的字符矩阵,对于每个子矩阵的每一行可以任意交换字符的顺序,使得每一行每 ...

  5. Codeforces Round #236 (Div. 2)E. Strictly Positive Matrix(402E)

    E. Strictly Positive Matrix   You have matrix a of size n × n. Let's number the rows of the matrix f ...

  6. Codeforces Round #277 (Div. 2) B.OR in Matrix 模拟

    B. OR in Matrix   Let's define logical OR as an operation on two logical values (i. e. values that b ...

  7. Codeforces Round #486 (Div. 3) E. Divisibility by 25

    Codeforces Round #486 (Div. 3) E. Divisibility by 25 题目连接: http://codeforces.com/group/T0ITBvoeEx/co ...

  8. Codeforces Round #486 (Div. 3) D. Points and Powers of Two

    Codeforces Round #486 (Div. 3) D. Points and Powers of Two 题目连接: http://codeforces.com/group/T0ITBvo ...

  9. Codeforces Round #297 (Div. 2)D. Arthur and Walls 暴力搜索

    Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 Sec  Memory Limit: 512 MBSubmit: xxx ...

随机推荐

  1. SpringBoot在线预览PDF文件(引用pdf.js工具)

    本项目Demo使用了PDF.js插件实现PDF在线阅读功能PDF.js插件下载地址 实测能用! 1.创建SpringBoot项目,目录结构如下: 2.进行项目配置: pom.xml: <proj ...

  2. JSON.parse()和JSON.stringfy()区别

    JSON.parse() 用于从一个json格式字符串解析出json类型的数据,如: 注意事项:json格式字符串必须是写在一排的,且括号外面用单引号,里面的每一个字符串用双引号 JSON.strin ...

  3. 程序语言与编程实践4-> 蓝桥杯C/C++备赛记录2 | 第二周学习训练

    0323,又是一周星期三,按道理该总结了.这周前几天写题比较多,后面事情多了起来,就没怎么写了.主要方向是洛谷的基本语法熟悉,PTA平台数据结构的一些题目. 0323附上: 题目比较多,所以文章可能有 ...

  4. springcloud学习03-spring cloud eureka(上)

    对eureka一个大概介绍:https://blog.csdn.net/u010623927/article/details/88762525 这里面有个我做dubbo时的一个理解的错误:服务注册中不 ...

  5. EasyUI 之datagrid 使用 【DataGrid属性解释】

    可选的参数 DataGrid 属性 覆写了 $.fn.datagrid.defaults. 参数名 类型 描述 默认值 title string Datagrid面板的标题 null iconCls ...

  6. SIMOTION D435-2 PN报错1915,无法进入RUN状态 解决方法

    1.现象 2.解决方法 以下几种情况会导致SIMOTION D CPU无法RUN状态: 1.SIMOTION D设置CPU上电后自动进入RUN状态,上电后D4x5 CPU准备就绪,开始执行系统任务区的 ...

  7. 统计分析— 1.SPSS数据编辑窗口 输出窗口 语法窗口

    第一课-SPSS窗口 一 数据编辑窗口(Data Editor) 二 输出窗口(Output Viewer ) 三 语法窗口(Syntax Editor):针对中高级用户,有些操作可以通过输入代码的方 ...

  8. SP接口的全双工首发接口整合

    unsigned char bits = 8; unsigned int speed = 50000; unsigned short delay; static void spi_transfer_d ...

  9. Nacos 使用

    Nacos(一)-下载安装 https://blog.csdn.net/qq_21067307/article/details/103895607  转载                        ...

  10. 使用redis作为django缓存数据库

    1.Redis的Windows版本.打开https://github.com/MSOpenTech/redis/releases下载msi安装包.该版本是64位.安装msi过程中,有个选项是否加入系统 ...