首页 > 其他 > 详细

Codeforces 1294A Collecting Coins

时间:2020-02-01 23:41:52      阅读:83      评论:0      收藏:0      [点我收藏+]

传送门

题意:

给4个整数,\(a,b,c,n\),然后把分成3份分别位A,B,C,(A+B+C=n)
问是否有一种分的方式满足 \(a + A = b + B = c + C\)
满足输出yes,否则输出no

思路:

如果a+b+c+n不是3的倍数,肯定不满足,从题目中可以看出,A,B,C>=0,判断一下即可

代码:

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
const int mod=998244353;
const int MAXN=2e5+50;
const double pi=3.1415926536;
int t;

int main()
{
    //freopen("in.txt","r",stdin);
    scanf("%d",&t);
    while(t--){
        int a,b,c,n;
        scanf("%d%d%d%d",&a,&b,&c,&n);
        int ans=a+b+c+n;
        if(ans%3!=0){
            printf("NO\n");
            continue;
        }
        else
        {
            int p=ans/3;
            if(a<=p&&b<=p&&c<=p)printf("YES\n");
            else printf("NO\n");
        }
    }
    return 0;
}

Codeforces 1294A Collecting Coins

原文:https://www.cnblogs.com/zzl_Alexander/p/12250583.html

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