codeforce B
Posted ronnielee
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeforce B相关的知识,希望对你有一定的参考价值。
cf B题,莫名其妙过,g++显示输入输出%lld有问题,,,明天改吧
By ronnie14165, contest: XDU_ACM_SUMMER ROUND 5 (Based on Educational Codeforces Round 49), problem: (B) Numbers on the Chessboard, Accepted, #
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
long long n;
int T;
long long ans;
long long a, b;
long long fun ( )
{
if(n%2==0)
{
if(a%2==0&&b%2==0) ans = n/2*(a-1)+b/2;
if(a%2==1&&b%2==1) ans = n/2*(a-1)+(b+1)/2;
if(a%2==1&&b%2==0) ans = n/2*(a-1)+b/2+n*n/2;
if(a%2==0&&b%2==1) ans = n/2*(a-1)+(b+1)/2+n*n/2;
}
if(n%2==1)
{
if(a%2==0&&b%2==0) ans = n*(a-2)/2+b/2+(n+1)/2;
if(a%2==1&&b%2==1) ans = n*(a-1)/2+(b+1)/2;
if(a%2==1&&b%2==0) ans = n*(a-1)/2+b/2+n*n/2+1;
if(a%2==0&&b%2==1) ans = n*(a-2)/2+(b+1)/2+n*n/2+1+(n-1)/2;
}
return ans;
}
int main()
{
cin >> n >> T;
while(T--)
{
//scanf("%l64d%l64d",&a,&b);
scanf("%lld%lld",&a,&b);
long long temp = fun();
printf("%lld
",temp);
}
return 0;
}
以上是关于codeforce B的主要内容,如果未能解决你的问题,请参考以下文章
(Incomplete) Codeforces 394 (Div 2 only)
Codeforces Round #746 (Div. 2)(A,B,C)