zoukankan      html  css  js  c++  java
  • Codeforces 1294A Collecting Coins

    传送门

    题意:

    给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
    ");
                continue;
            }
            else
            {
                int p=ans/3;
                if(a<=p&&b<=p&&c<=p)printf("YES
    ");
                else printf("NO
    ");
            }
        }
        return 0;
    }
    
  • 相关阅读:
    洛谷 P1141 01迷宫
    洛谷 p1443
    setw
    Fliptile
    追牛
    Dungeon Master
    vim的一些基本操作
    洛谷 p1309 瑞士轮
    洛谷 p1090 合并果子
    selenium2 WebDriver 在asp.net项目中的应用
  • 原文地址:https://www.cnblogs.com/zzl_Alexander/p/12250583.html
Copyright © 2011-2022 走看看