B.Obtain Two Zeroes
题目:包含两个零##
题意:你被给予两个数a和b,你可以对这两个数进行操作
每次操作你可以选择任意的正整数x,可以进行a = a - x,b = b - 2x或者a = a - 2x,b = b - x两种操作
是否可以让两个整数同时变为0
输出"YES"或者"NO"
分析:可以把相同减去的第一种操作全都合并为x,第二种操作全都合并为y
可以得到a - x - 2 * y = 0,b - 2 * x - y = 0
通过这两个等式,可以得到(a + b) = 3 * x + 3 * y,说明可以被(a + b)可以被3整除
条件里存在x > 0和y > 0,通过上面的等式,可以得到3x = 2 * a - b,3y = 2 * b - a,
可以得到2 * a > b,2 * b > a,得到2a > b > a/2
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int t;
bool sentence(int a, int b)
{
if (2 * a >= b && 2 * b >= a && (a + b) % 3 == 0)
return true;
else
return false;
}
int main()
{
scanf("%d", &t);
while (t--)
{
int a, b;
scanf("%d%d", &a, &b);
if (sentence(a, b))
{
puts("YES");
}
else {
puts("NO");
}
}
return 0;
}
B.Obtain Two Zeroes的更多相关文章
- Codeforce |Educational Codeforces Round 77 (Rated for Div. 2) B. Obtain Two Zeroes
B. Obtain Two Zeroes time limit per test 1 second memory limit per test 256 megabytes input standard ...
- CF-Educational Codeforces Round 77 (Rated for Div. 2)(A-E题解)
A. Heating (水题) 题目链接 大致思路: 因为是代价是平方,所以让每一个房间的大小平均即可,即最大和最小相差不超过一. 代码: #include<bits/stdc++.h> ...
- Codeforces 1260 ABC
DEF 题对于 wyh 来说过于毒瘤,十分不可做. A. Heating Description: 给定\(a,b\),将\(b\)分成至少\(a\)个正整数,使这些正整数的平方和最小. Soluti ...
- Java 计算N阶乘末尾0的个数-LeetCode 172 Factorial Trailing Zeroes
题目 Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in ...
- [LeetCode] Factorial Trailing Zeroes 求阶乘末尾零的个数
Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in log ...
- [LintCode] Trailing Zeroes 末尾零的个数
Write an algorithm which computes the number of trailing zeros in n factorial. Have you met this que ...
- 环信SDK报错处理方法obtain an updated library from the vendor, or disable bitcode for this target. for archit
ld: '/Users/momo/Desktop/ThreeFingers/Pods/EaseMobSDKFull/EaseMobSDKFull/lib/libEaseMobClientSDK_arm ...
- MS SQL Could not obtain information about Windows NT group/user 'domain\login', error code 0x5. [SQLSTATE 42000] (Error 15404)
最近碰到一个有趣的错误:海外的一台数据库服务器上某些作业偶尔会报错,报错信息如下所示: -------------------------------------------------------- ...
- Could not obtain information about Windows NT group/user 'xxxx\xxxx', error code 0x5
案例描述 昨晚踢球回来,接到电话说一个系统的几个比较重要作业出错,导致系统数据有些问题.让我赶紧检查看看.检查作业日志时发现,作业报如下错误(关键信息用xxx替换) The job failed. ...
随机推荐
- 第五天、vim,重定向,用户和组管理
第五天.vim,重定向,用户和组管理 vim vi:Visual editor,文本编辑器 行编辑器:sed 全屏编辑器:vim,vi,nano 其他编辑器gedit,gvim 定义别名让vi等于vi ...
- vue-create 报错 command failed: yarn --registry=https://registry.npm.taobao.org --disturl=https://npm.taobao.org/dist 完美解决方案
@vue/cli 3.x 创建项目失败解决方案 报错信息 command failed: yarn --registry=https://registry.npm.taobao.org --distu ...
- Appium+python自动化(四十二)-Appium自动化测试框架综合实践- 寿终正寝完结篇(超详解)
1.简介 按照上一篇的计划,今天给小伙伴们分享执行测试用例,生成测试报告,以及自动化平台.今天这篇分享讲解完.Appium自动化测试框架就要告一段落了. 2.执行测试用例&报告生成 测试报告, ...
- nyoj 467 中缀式变后缀式 (栈)
中缀式变后缀式 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 人们的日常习惯是把算术表达式写成中缀式,但对于机器来说更“习惯于”后缀式,关于算术表达式的中缀式和后缀 ...
- 结合Spring Security进行web应用会话安全管理
在本文中,将为大家说明如何结合Spring Security 和Spring Session管理web应用的会话. 一.Spring Security创建使用session的方法 Spring Sec ...
- C# 彻底搞懂async/await
前言 Talk is cheap, Show you the code first! private void button1_Click(object sender, EventArgs e) { ...
- Install zabbix
- name: Create dir to keep install file file: path=/opt/pacheage state=directory follow=yes force=ye ...
- Java 9 ← 2017,2019 Java → 13 ,都发生了什么?
距离 2019 年结束,只剩下 35 天了.你做好准备迎接 2020 年了吗? 一到年底,人就特别容易陷入回忆和比较之中,比如说这几天, 的对比挑战就火了! 这个话题登上了微博的热搜榜,也刷爆了朋友圈 ...
- 【前端】 在前端利用数学函数知识+box-shadow解波浪图形
序 今天正在刷数学函数相关题目,刷到了下面这篇文章,哇哦-有意思. 利用cos和sin实现复杂的曲线.传送门在下面. CSS 技巧一则 -- 在 CSS 中使用三角函数绘制曲线图形及展示动画 正巧在复 ...
- PHP安装sodium加密扩展
1.为什么会用到sodium加密扩展? 最近在做微信服务商相关的开发,主要用的的接口为微信小微商户进件接口.在请求相关接口中,需要对一些敏感字段进行加密,加密过程见https://pay.weixin ...