zoukankan      html  css  js  c++  java
  • codeforce B

    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
    ",temp);
        }
        
        return 0;
    }
    
    透过泪水看到希望
  • 相关阅读:
    Super Mario
    SPOJ Count on a tree
    SPOJ DQUERY
    51nod 区间中第K大的数
    POJ2104 K-th Number
    矩阵模板
    Sasha and Array
    MVC RenderSection
    Lazy Acquisition
    .net4.5 await async 简化之后的异步编程模型
  • 原文地址:https://www.cnblogs.com/ronnielee/p/9503402.html
Copyright © 2011-2022 走看看