地址 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. phpcms 2008 变量覆盖漏洞

    一. 启动环境 1.双击运行桌面phpstudy.exe软件 2.点击启动按钮,启动服务器环境 二.代码审计 1.双击启动桌面Seay源代码审计系统软件 3.点击新建项目按钮,弹出对画框中选择(C:\ ...

  2. 论php常见的问题[转载自原乌云]

    论PHP常见的漏洞 ′ 雨. · 2015/01/14 10:08 0x00 前言 里面很多都是像laterain学习到的, 如果能考上cuit的话 自动献菊花了. 0x01 安装的问题 首先拿到一份 ...

  3. K8S原来如此简单(八)ServiceAccount+RBAC

    ServiceAccount ServiceAccount是给运行在Pod的程序使用的身份认证,Pod容器的进程需要访问API Server时用的就是ServiceAccount账户. Service ...

  4. 为什么JVM要用到压缩指针?Java对象要求8字节的整数倍?

    前言 前两天在一个帖子中看到一道面试题: 堆内存超过32G时,为什么压缩指针失效? 之前没有了解过这方面的知识,于是开始google起来,但当我翻看了不下一页的帖子,我都仍然没有搞懂,因为好多答案给我 ...

  5. ES6中对象新增的方法

    属性的简洁表示法 ES6 允许在大括号里面直接写入变量和函数,作为对象的属性和方法.这样的书写更加简洁. const foo = 'bar'; const baz = { foo }; console ...

  6. Spring-boot-菜鸟-properties配置

    如果测试结果出现中文乱码: 结果": Person{lastName='张胜男', age=11, boss=false, birth=Wed Nov 11 00:00:00 CST 202 ...

  7. 创建Maven web工程

    ---恢复内容开始--- 第一步,启动Eclipse,依次打开菜单[File][New][Other] 找到目录Maven,选择Maven Project, 选择一个Archetype.这里创建Web ...

  8. Mybatis入门程序(二)

    1.实现需求 添加用户 更新用户 删除用户 2.添加用户 (1)映射文件User.xml(Mapper)中,配置添加用户的Statement <!-- 添加用户: parameterType:指 ...

  9. 学习Apache(三)

    对某个目录开启验证登录 <Directory /var/www/html/admin > AllowOverride All Order allow,deny Allow from all ...

  10. javascript新手实例1-DOM基本操作

    学习javascript好多同学不知道怎么上手,跟着网上的新手教程做了一遍又觉得javascript很简单,但是真正自己用起来又觉得写不出什么东西,我觉得学习最好的方法就是跟着有趣的例子做,所以我们的 ...