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. ...
随机推荐
- 关于RAID 5的介绍与创建
一.简介 定义: RAID 5是RAID 0和RAID 1的折中方案.RAID 5具有和RAID0相近似的数据读取速度,只是多了一个奇偶校验信息,写入数据的速度比对单个磁盘进行写入操作稍慢.同时由于多 ...
- [NLP] Adaptive Softmax
1. Overview Adaptive softmax算法在链接1中的论文中提出,该算法目的是为了提高softmax函数的运算效率,适用于一些具有非常大词汇量的神经网络. 在NLP的大部分任务中,都 ...
- Linux\CentOS 安装 vsftpd 服务器
安装 查看电脑是否存在 vsftpd 服务器 rmp -qa|grep vsftpd 如果有就删除,没有就使用yum 安装 vsftpd yum -y install vsftpd 配置 在根目录下创 ...
- [学习笔记] 在Eclipse中使用Hibernate,并创建第一个工程
在Eclipse中使用Hibernate 安装 Hibernate Tools 插件 https://tools.jboss.org/downloads/ Add the following URL ...
- 【Stream—7】NetworkStream相关知识分享
一.NetworkStream的作用 和先前的流有所不同,NetworkStream的特殊性可以在它的命名空间中得以了解(System.Net.Sockets),聪明的你马上就会反应过来:既然是在网络 ...
- goroutiine同步/channel、互斥锁、读写锁、死锁/条件变量
1. Goroutine同步[数据同步] 为什么需要goroutine同步 gorotine同步概念.以及同步的几种方式 1.1 为什么需要goroutine同步 package main impor ...
- H3C交换机DHCP基础配置案例 v7版本
一.需求 要求在Switch A上配置DHCP服务器功能实现:• 为网络内的客户端动态分配 10.1.1.0/24 网段内的 IP 地址.租用有效期限. DNS 信息.网关地址等配置信息:• 根据 S ...
- JavaScript笔记八
1.原型(prototype) - 创建一个函数以后,解析器都会默认在函数中添加一个数prototype prototype属性指向的是一个对象,这个对象我们称为原型对象. - 当函数作为构造函数使用 ...
- Linux三个比较特殊的权限
Linux还有三个比较特殊的权限,分别是:setuid,setgid,stick bit . -:表示一般文件 d:表示目录文件 l:表示链接文件 b:表示块设备 c:表示字符设备 p:表示管道 s: ...
- 《手把手教你》系列练习篇之7-python+ selenium自动化测试 -压轴篇(详细教程)
1. 简介 “压轴”原本是戏曲名词,指一场折子戏演出的倒数第二个剧目.在现代社会中有很多应用,比如“压轴戏”,但压轴也是人们知识的一个盲区.“压轴”本意是指倒数第二个节目,而不是人们常说的倒数第一个, ...