题目:
Polycarp has three sisters: Alice, Barbara, and Cerene. They’re collecting coins. Currently, Alice has a coins, Barbara has b coins and Cerene has c coins. Recently Polycarp has returned from the trip around the world and brought n coins.

He wants to distribute all these n coins between his sisters in such a way that the number of coins Alice has is equal to the number of coins Barbara has and is equal to the number of coins Cerene has. In other words, if Polycarp gives A coins to Alice, B coins to Barbara and C coins to Cerene (A+B+C=n), then a+A=b+B=c+C.

Note that A, B or C (the number of coins Polycarp gives to Alice, Barbara and Cerene correspondingly) can be 0.

Your task is to find out if it is possible to distribute all n coins between sisters in a way described above.

You have to answer t independent test cases.

Input
The first line of the input contains one integer t (1≤t≤104) — the number of test cases.

The next t lines describe test cases. Each test case is given on a new line and consists of four space-separated integers a,b,c and n (1≤a,b,c,n≤108) — the number of coins Alice has, the number of coins Barbara has, the number of coins Cerene has and the number of coins Polycarp has.

Output
For each test case, print “YES” if Polycarp can distribute all n coins between his sisters and “NO” otherwise.

Example
Input
5
5 3 2 8
100 101 102 105
3 2 1 100000000
10 20 15 14
101 101 101 3

Output
YES
YES
NO
NO
YES

代码

#include<bits/stdc++.h>
using namespace std;
int main()
{int t,A,B,C,n,maxn=0;scanf("%d",&t);for(int i=0;i<t;i++){scanf("%d %d %d %d",&A,&B,&C,&n);maxn=max(A,B);maxn=max(maxn,C);//max()函数返回最大值; if(n>=maxn*3-A-B-C&&(n-(maxn*3-A-B-C))%3==0){printf("YES\n");}else{printf("NO\n");}}return 0;
}

Collecting Coins相关推荐

  1. 基础算法 —— 模拟思维

    [概述] 模拟,是根据实际问题建立模型,模拟实际按程序走一遍,最终求出答案. 思维,则是与逻辑思维有关,其需要针对题意.数据范围等抽丝剥茧抽离出有用的信息,从而得出一个结果. 对于一般的模拟,直接根据 ...

  2. c语言 英语试卷,英语听力试题及答案

    英语听力试题及答案 Section One: Listening Comprehension Part A 1.Hell help Tina prepare for the meeting. Hes ...

  3. 用计算机唱歌弹奏china,新目标英语专题练习:句型转换(附答案)

    新目标八年级上期末复习(同义句) 1.       He always gets to school early. = He never gets to school late. 2.       M ...

  4. 计算机网络时间校时,若当前系统时间与标准时间误差在( )分钟内,需进行校准。出处:《计算机化系统时钟校准管理规程》MS-E050。...

    若当前系统时间与标准时间误差在( )分钟内,需进行校准.出处:<计算机化系统时钟校准管理规程>MS-E050. 更多相关问题 发生人工费索赔时能按日计工费计算的是( ). 工业的飞速进步使 ...

  5. Codeforces Round #615 (Div. 3)

    怎么说呢,总之Div3还是蛮有意思的吧! Collecting Coins #include<bits/stdc++.h> using namespace std; typedef lon ...

  6. 《薄冰实用英语语法详解》独家连载之十四:介词

    介词的种类.短语及搭配 介词(The Preposition)又叫做前置词,通常置于名词之前.它是一种虚词,不需要重读,在句中不单独作任何句子成分,只表示其后的名词或相当于名词的词语与其他句子成分的关 ...

  7. 初三英语关于计算机的作文,初三毕业英语作文(精选11篇)

    初三毕业英语作文(精选11篇) 无论是身处学校还是步入社会,大家一定都接触过作文吧,通过作文可以把我们那些零零散散的思想,聚集在一块.你知道作文怎样才能写的好吗?以下是小编为大家收集的初三毕业英语作文 ...

  8. python调用文件下载接口_python接口自动化21-下载excel文件(Content-Type:octets/stream)...

    前言 Content-Type类型为octets/stream,这种一般是文件类型了,比如有时候需要导出excel数据,下载excel这种场景如何用python来实现呢? 抓下载接口 1.下载的场景如 ...

  9. 英文简历各部分写作对策

    英文简历各部分写作对策 更新日期:2006-4-4     文章来源:http://www.liuxuehome.com     浏览次数:1830 次   偶然在电脑里翻到,我都忘记什么时候保存的了 ...

  10. 初中英语听力计算机考试反馈,初中英语听力试题与答案

    ★无忧考网英语听力频道为大家整理的初中英语听力试题与答案,供大家参考.更多阅读请查看本站英语听力频道. 第一节(共5小题:每小题1.5分,满分7.5分) 听下面5段对i舌征段对话后有一个小题,从题中所 ...

最新文章

  1. html5游戏 虚拟主机,基于HTML5的云虚拟主机配置界面
  2. 怎样解决VMware虚拟机无法连接外网问题
  3. idea自动生成类注释和方法注释
  4. code vs 代码格式化排版_23行代码,教你用python实现百度翻译!(建议收藏)
  5. BI(商务智能)是对商业数据进行价值提取的过程
  6. G盘文件系统RAW要怎么办啊
  7. 《SaaS架构设计》新书SD会议首发签售
  8. 北大青鸟S1结业项目团队第一名——Myktv前端
  9. 文件服务器实验报告,Server 2008 R2 文件服务器资源管理器实验报告.docx
  10. 2021年全国各行业统计年鉴整理
  11. npm 可视化html编辑器,Vue + element从零打造一个H5页面可视化编辑器——pl-drag-template...
  12. oracle10g_database安装教程,Oracle Database 10g数据库安装及配置教程
  13. 虚拟机修改ip地址的操作步骤
  14. 安卓漫漫路之实现简单的弹幕.
  15. The Matrix--庄生晓梦迷蝴蝶
  16. 塔望食业洞察|植物肉行业发展趋势 品牌竞争格局及未来发展
  17. 金刚菩提子开裂自动修复此计算机,金刚菩提子裂了怎么办 教你这些修复方法...
  18. html页面涂鸦,HTML5 | Canvas画笔小应用(涂鸦板)
  19. CentOS7.2时间不正确
  20. 惠普电脑如何重装Linux系统,如何把惠普下的Linux操作系统换为windows 7

热门文章

  1. DeepFaceLab教程 DeepFaceLab新手入门教程
  2. RFID工作频率的分类
  3. 关于芯片最高工作频率的计算
  4. 详解电脑机械硬盘装什么系统好
  5. 不会做PPT图表?1000个高大上的PPT图表,0门槛0套路,想要就给你
  6. ios下拉效果滑动滚出页面
  7. TensorFlow之saved_model使用笔记
  8. 问题:office应用(word、ppt、excel、oneNote) 您的组织策略阻止我们为您完成此操作 解决办法
  9. python鸡兔同笼头35只_python_鸡兔同笼问题
  10. POS机交易支付知识点整理