美文网首页
CodeFoeces-950A

CodeFoeces-950A

作者: ss5smi | 来源:发表于2018-03-10 16:00 被阅读0次

题目

原题链接:A. Left-handers, Right-handers and Ambidexters

题意

给出l和r,可用a补充,问l==r时l和r最大的和。

代码

#include<bits/stdc++.h>
using namespace std;
int main() {
    int l,r,a;
    cin>>l>>r>>a;
    if((l==0 || r==0) && a==0) {
        printf("0\n");
        return 0;
    }
    int t=abs(l-r);
    if(a<=t) printf("%d\n",l>r?(r+a+r+a):(l+a+l+a));
    else a-=t,printf("%d\n",l>r?(l+l+(a%2==0?a:a-1)):(r+r+(a%2==0?a:a-1)));
    return 0;
}

相关文章

  • CodeFoeces-950A

    题目 原题链接:A. Left-handers, Right-handers and Ambidexters 题意...

网友评论

      本文标题:CodeFoeces-950A

      本文链接:https://www.haomeiwen.com/subject/ktivfftx.html