首页 > 其他 > 详细

codeforce B

时间:2018-08-20 00:52:47      阅读:220      评论:0      收藏:0      [点我收藏+]

cf B题,莫名其妙过,g++显示输入输出%lld有问题,,,明天改吧

原题(http://codeforces.com/gym/227252/standings/friends/true

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\n",temp);
    }
    
    return 0;
}

codeforce B

原文:https://www.cnblogs.com/ronnielee/p/9503402.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!