Educational Codeforces Round 49 (Rated for Div. 2) B. Numbers on the Chessboard

Twin Builder CFD 示例:构建、验证和评估静态 ROM 通过我们构建、验证和评估静态 ROM 的综合指南,释放 Twin Builder CFD 的潜力。 阅读详情
  1. problem link:http://codeforces.com/contest/1027/problem/B
  2. 可以分解开来找规律:看图
    横纵坐标之和为偶数
    以n为4为例,每行有n/2个数。结合坐标特点得出规律。
    横纵坐标之和为奇数

  3. AC code:

#include<iostream>
using namespace std;
typedef long long ll;
ll n,q,a,b,ans;
int main(){
    cin>>n>>q;
    while(q--){
        cin>>a>>b;
        ans=(a-1)*n+b+1;
        if((a+b)%2)ans+=n*n;
        cout<<ans/2<<endl;
    }
}

相关推荐

零样本缺陷检测新体验:用AnomalyGPT大模型快速搭建智能质检系统(附Win10适配指南)

本文详细介绍了如何利用AnomalyGPT大模型在Windows 10系统上快速搭建零样本工业缺陷检测系统。通过实战指南,涵盖从环境部署、模型准备到工程化落地的全过程,包括将模型封装为API服务、接入工业相机以及开发可视化监控看板,为制造业智能质检提供了一套高效、低门槛的本地部署解决方案。

weixin_29094775的博客 310

Educational Codeforces Round 49 (Rated for Div. 2)

链接:http://codeforces.com/contest/1027 目录 A.Palindromic Twist 题目 题解 代码 B.Numbers on the Chessboard 题目 题解 代码 C.Minimum Value Rectangle 题目 题解: 代码 D.Mouse Hunt 题目 题解 代码 A.Palindromic Twi...

zxwsbg的博客 382

# 执行 DISM 命令时出错 87 未在此上下文中识别出 restorehealth 选项。解决方法

# 执行 DISM 命令时出错 87 未在此上下文中识别出 restorehealth 选项。解决方法

段子手168的博客 1万+

B. Numbers on the Chessboard -codeforces1027 -csdn博客

B. Numbers on the Chessboard -codeforces1027 -csdn博客 You are given a chessboard of size n×n. It is filled with numbers from 1 to n2 in the following wa...

i-Curve的博客 359

算法设计与分析 0-1背包问题 动态规划解法【超详细】

0-1背包问题 问题描述 给定i个物品和一个容量为的背包,物品的重量是Wi,其价值为Vi 物品个数为i,背包容量为C。 如何选择装入背包内的物品,使得装入背包中的物品的总价值最大? 其中,每种物品只有全部装入背包或不装入背包两种选择。 物品不能分割,不能重复使用。 动态规划算法思路 首先建立一个数组B[i][c],最上面一行表示背包容量,最左边一列表示物品编号,中间填充的数值表示当当前背包容量为C...

寒泉 4万+

Android BLE扫描指南:解决设备发现问题

假设你正在开发一个MAUI应用,用于扫描并连接到BLE设备。你的代码在Windows上运行得很好,但在Android上却无法发现任何设备。尽管你已经在中声明了必要的权限,并且在运行时请求这些权限,扫描还是无法工作。

m0_62153576的博客 224

【CF】B- Numbers on the Chessboard

B. Numbers on the Chessboard time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a chessboard of size n×n . It is fille...

Whyckck的博客 681

对角两对双差速轮AGV的平移、直行、转弯和原地旋转之PID控制

本示例将展示如何使用PID控制算法,控制具有对角线布置的两对双差速轮(左前和右后)的AGV,实现平移、直行、转弯和原地旋转等运动。通过对车辆的运动学和PID控制器的设计,我们可以精确地控制AGV的运动

xiaoc100200的博客 1510

【CF 1027B】Numbers on the Chessboard

                            B. Numbers on the Chessboard You are given a chessboard of size n×nn×n. It is filled with numbers from 11 to n2n2 in the following way: the first ⌈n22⌉⌈n22⌉numbers from 11...

Xylon的博客 702

51单片机入门指南-基于STC89C52(持续更新)

一、环境介绍 编程IDE: keil5 单片机型号: STC89C51/52 开发板: 普中科技的开发板 完整PDF资源下载地址:https://download.csdn.net/download/xiaolong1126626497/19785856 二、51单片机开发手册介绍 2.1 前言 51单片机是对所有兼容Intel 8031指令系统的单片机的统称。 该系列单片机的始祖是Intel的8004单片机,后来随着Flash rom技术的发展,8004单片机取得了长足的进展,成为应用最.

8798

1 硬件工程师笔面试高频知识考点真题及解析——电阻

本文系统介绍了电阻的基础知识、选型要点及各类特殊电阻的应用。主要内容包括:1. 电阻选型需考虑阻值、封装、功率、精度、耐压等参数;2. 高频信号优先选用小封装电阻以减小寄生参数;3. 采样电阻需高精度、低温漂以保证测量准确性;4. 详细解析了上拉/下拉电阻、0欧电阻、磁珠等元件的特性与区别;5. 介绍了压敏电阻、热敏电阻等特殊电阻的工作原理及应用场景;6. 阐述了阻抗匹配的重要性及常见匹配方法。文章为电子工程师提供了全面的电阻选型与应用指南。

XU157303764的博客 2851

B.Numbers on the Chessboard(矩阵中放数)

题目链接 题意: 题意:在矩阵里面放数,先把横纵坐标之和是偶数的放满,从左往右,从上往下,然后从最小的奇数(横纵坐标之和)开始继续往后放数;直到把n*n这些数放完 #include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; #include&lt;string.h&gt; int main() { long long int n,m; ...

小自洽 579

打通ZYNQ的任督二脉:AXI_FIFO数据交互全解析

FIFO(First In First Out,先进先出)是一种经典的数据缓冲结构,就像排队买票一样,先来的人先得到服务。时钟域交叉(CDC):连接不同时钟频率的模块数据缓冲:平衡生产者和消费者的速度差异流量控制:防止数据丢失或溢出input clk,// 输入AXI4-Stream接口(从PS到PL)// 输出AXI4-Stream接口(从PL到PS)// 状态指示信号// 定义状态机状态// 数据缓存// 8个深度的缓存// 流水线处理寄存器。

QQ_778132974的博客 305

Educational Codeforces Round 49 (Rated for Div. 2) B. Numbers on the Chessboard

Examples input 4 5 1 1 4 4 4 3 3 2 2 4 output 1 8 16 13 4 input 5 4 2 1 4 2 3 3 3 4 output 16 9 7 20 题意:有一个n*n的方格,先给行(i)、列(j)相加为偶数的格子依次填上编号,再给行列相加为奇数的格子填上编号。现要求某行某列的方格中填的数是多少。 ...

Marystl的博客 307

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Numbers on the Chessboard- Educational Codeforces Round 49 (Rated for Div. 2)B题

思路: 找规律即可。 AC code: #include&lt;bits/stdc++.h&gt; using namespace std; int main(){ int n = 0,q = 0; while(cin &gt;&gt; n &gt;&gt; q){ int me = 0,mo = 0; int start = 0; ...

我们花时间收集,却忘了最重要的其实是花时间去消化 201

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

cf.B. Numbers on the Chessboard

这是一道简单题,主要考查思维,你可以很容易的发现,他是两行一循环的,也就是每两行格式是一样的。而且只要你找到当前位置是第几个数,再跟据找到的规律,直接赋值就行了。 #include<bits/stdc++.h> using namespace std; int main() { long long int n , q; ios::sync_with_stdio(false); c...

小飞猪的博客 260

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

CF Educational Codeforces Round 49 (Rated for Div. 2)

D题 #include &lt;bits/stdc++.h&gt; using namespace std; int c[222000]; int a[222000]; int vis[222000]; int temp; int sk[202000]; int top; int main(){ int n; cin&gt;&gt;n; for(int i=1;i&lt;...

CODER的博客 414

【Codeforces】B. Numbers on the Chessboard

B. Numbers on the Chessboard 题目链接 time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a chessboard of sizen×nn×n. It i...

x_mn的博客 2734

Educational Codeforces Round 49 (Rated for Div. 2)A. Palindromic Twist

problem link:http://codeforces.com/contest/1027/problem/A 第一次写用了48行,第二次写用了12行。还是做题太少。心塞塞。 小闵呀,加油!!! #include&lt;bits/stdc++.h&gt; using namespace std; int main(){ int T;cin&gt;&gt;T; while...

Light2Chasers的博客 806

Educational Codeforces Round 49 (Rated for Div. 2) C. Minimum Value Rectangle

C. Minimum Value Rectangle time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have nn sticks of the given lengths. Your task is...

哇-WA 的博客 232

Numbers on the Chessboard(CF-1027B)

Problem Description You are given a chessboard of size n×n. It is filled with numbers from 1to n^2in the following way: the first ⌈n^2/2⌉ numbers from 1 to ⌈n^2/2⌉ are written in the cells with ev...

Alex_McAvoy的博客 500

CodeForces - 1027B Numbers on the Chessboard(找规律)

题目: 传送门 思路: 若 n 为偶 ,则 每行 nn /2 之前和之后的数的个数相等 , 为 奇 ,则 每行 nn /2 之前和之后的数的个数与 行的奇偶有关。 int main() { long long n, q; cin >> n >> q; long long mids = (n*n - 1) / 2 + 1; while(q--) { long lo...

JingluoZZZ 284

Codeforces Round #427 (Div. 2)-B. The number on the board

题目:                                        B. The number on the board Some natural number was written on the board. Its sum of digits was not less than k. But you were distracted a bit, and some

愚者 1163

Numbers on the Chessboard

You are given a chessboard of size n×nn×n. It is filled with numbers from 11 to n2n2 in the following way: the first ⌈n22⌉⌈n22⌉ numbers from 11 to ⌈n22⌉⌈n22⌉ are written in the cells with even sum of ...

starlet_kiss的博客 530

CF1027B Numbers on the Chessboard (#数学)

题目描述 You are given a chessboard of sizen \times nn×n. It is filled with numbers from11ton^2n2in the following way: the first\lceil \frac{n^2}{2} \rceil⌈2n2​⌉numbers from11to\lceil \frac{n^...

A.pro的博客 457

Educational Codeforces Round 49 (Rated for Div. 2) D. Mouse Hunt

题目大意 有nnn个房间,每个房间都有一条连出去的通道,连向另一个房间aia_iai​。 初始时刻,老鼠会出现在[1,n][1,n][1,n]中的任意一个房间里。 下一个时刻,老鼠将沿着这个房间连出去的通道,逃跑到另一个房间。 现在要在房间里布置陷阱来抓捕老鼠,在第iii个房间里布置一个陷阱需要花费cic_ici​的代价。 假设陷阱很强,一定能抓到跑到该房间的老鼠。 问最少要花费多少代价,才能保证无论初始时刻老鼠出现在哪一个房间都能把老鼠抓获。 时间限制 2s 数据范围 n≤2×105n\le 2\time

lijf2001的博客 325
上一篇: Educational Codeforces Round 49 (Rated for Div. 2)A. Palindromic Twist
下一篇: Educational Codeforces Round 49 (Rated for Div. 2) C. Minimum Value Rectangle
图南1204
博客等级 码龄9年 21粉丝 118原创
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值