Luntik and Concerts 结论,思维

在这里插入图片描述
题意 :

  • 有a首1分钟的歌,b首2分钟,c首3分钟,分成两场歌会,要求两场的时长差绝对值尽可能小,有 a , b , c > = 1 a,b,c>=1 a,b,c>=1

思路 :

  • 由于这三个数字每个都至少有1个,所以一定可以组合出 [ 1 , n ] [1, n] [1,n]中的任意一个数字,所以当 s u m sum sum为偶数时,一定可以分成 s u m / 2 + s u m / 2 sum/2 + sum/2 sum/2+sum/2 s u m sum sum为奇数时,差值绝对值为1
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

int main()
{
    
    
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int _;
    cin >> _;

    while (_ -- )
    {
    
    
        ll a, b, c;
        cin >> a >> b >> c;
        ll sum = a + b * 2 + c * 3;
        if (sum % 2) cout << 1 << endl;
        else cout << 0 << endl;
    }

    return 0;
}

猜你喜欢

转载自blog.csdn.net/m0_51448653/article/details/121234184