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

  1. problem link:http://codeforces.com/contest/1027/problem/B
  2. 可以分解开来找规律:看图
    Educational Codeforces Round 49 (Rated for Div. 2) B. Numbers on the Chessboard_第1张图片
    以n为4为例,每行有n/2个数。结合坐标特点得出规律。
    Educational Codeforces Round 49 (Rated for Div. 2) B. Numbers on the Chessboard_第2张图片

  3. AC code:

#include
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<2<

你可能感兴趣的:(模拟题目,codeforces)