zoukankan      html  css  js  c++  java
  • 2017 Multi-University Training Contest 5 hdu 6090

    HDU 6090

    思路:

    AC代码:

    #include "iostream"
    #include "string.h"
    #include "stack"
    #include "queue"
    #include "string"
    #include "vector"
    #include "set"
    #include "map"
    #include "algorithm"
    #include "stdio.h"
    #include "math.h"
    #pragma comment(linker, "/STACK:102400000,102400000")
    #define ll long long
    #define endl ("
    ")
    #define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
    #define mem(a,x) memset(a,x,sizeof(a))
    #define mp(x,y) make_pair(x,y)
    #define pb(x) push_back(x)
    #define ft (frist)
    #define sd (second)
    #define lrt (rt<<1)
    #define rrt (rt<<1|1)
    using namespace std;
    const long long INF = 1e18+1LL;
    const int inf = 1e9+1e8;
    const int N=1e5+100;
    const ll mod=1e9+7;
    
    ll n,m,ans;
    int main(){
        ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
        int T;
        cin>>T;
        while(T--){
            cin>>n>>m;
            if(m<=n-1){
                ll c=n-m-1;
                ans=2*m+2*(m-1)*m+2*(m+1)*c*n+c*(c-1)*n;
            }
            else{
                m-=n-1;
                ans=2*(n-1)+2*(n-1)*(n-2);
                ans-=2*m;
            }
            if(ans<n*(n-1)) ans=n*(n-1);
            cout<<ans<<endl;
        }
        return 0;
    }
  • 相关阅读:
    Mysql 从入门到遗忘
    Centos7开放及查看端口
    创建及修改数据库
    02_python是一种什么语言?
    03_SQL server数据类型
    02_关系数据库
    01_初识数据库
    kali 更新源
    01_Python简介
    Alertmanager高可用
  • 原文地址:https://www.cnblogs.com/max88888888/p/7420844.html
Copyright © 2011-2022 走看看