题目:包含两个零##

题意:你被给予两个数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的更多相关文章

  1. 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 ...

  2. CF-Educational Codeforces Round 77 (Rated for Div. 2)(A-E题解)

    A. Heating (水题) 题目链接 大致思路: 因为是代价是平方,所以让每一个房间的大小平均即可,即最大和最小相差不超过一. 代码: #include<bits/stdc++.h> ...

  3. Codeforces 1260 ABC

    DEF 题对于 wyh 来说过于毒瘤,十分不可做. A. Heating Description: 给定\(a,b\),将\(b\)分成至少\(a\)个正整数,使这些正整数的平方和最小. Soluti ...

  4. 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 ...

  5. [LeetCode] Factorial Trailing Zeroes 求阶乘末尾零的个数

    Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in log ...

  6. [LintCode] Trailing Zeroes 末尾零的个数

    Write an algorithm which computes the number of trailing zeros in n factorial. Have you met this que ...

  7. 环信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 ...

  8. MS SQL Could not obtain information about Windows NT group/user 'domain\login', error code 0x5. [SQLSTATE 42000] (Error 15404)

    最近碰到一个有趣的错误:海外的一台数据库服务器上某些作业偶尔会报错,报错信息如下所示: -------------------------------------------------------- ...

  9. Could not obtain information about Windows NT group/user 'xxxx\xxxx', error code 0x5

    案例描述 昨晚踢球回来,接到电话说一个系统的几个比较重要作业出错,导致系统数据有些问题.让我赶紧检查看看.检查作业日志时发现,作业报如下错误(关键信息用xxx替换) The job failed.  ...

随机推荐

  1. PHP 将数据从 Laravel 传送到 vue 的四种方式

    在过去的两三年里,我一直在研究同时使用 Vue 和 Laravel 的项目,在每个项目开发的开始阶段,我必须问自己 “我将如何将数据从 Laravel 传递到 Vue ?”.这适用于 Vue 前端组件 ...

  2. nyoj 75-日期计算 (闰年与平年的判断)

    75-日期计算 内存限制:64MB 时间限制:3000ms 特判: No 通过数:19 提交数:31 难度:1 题目描述: 如题,输入一个日期,格式如:2010 10 24 ,判断这一天是这一年中的第 ...

  3. .NET Core 获取数据库上下文实例的方法和配置连接字符串

    目录 .NET Core 获取数据库上下文实例的方法和配置连接字符串 ASP.NET Core 注入 .NET Core 注入 无签名上下文 OnConfigure 配置 有签名上下文构造函数和自己n ...

  4. 力扣(LeetCode)计数质数 个人题解

    统计所有小于非负整数 n 的质数的数量. 示例: 输入: 10 输出: 4 解释: 小于 10 的质数一共有 4 个, 它们是 2, 3, 5, 7 . 一般方法,也就是一般人都会用的,将数从2到它本 ...

  5. tar使用笔记

    解压到指定目录 -C tar -zxvf test.tar.gz -C /opt

  6. Asp.net Core 系列之--5.认证、授权与自定义权限的实现

    ChuanGoing 2019-11-24 asp.net core系列已经来到了第五篇,通过之前的基础介绍,我们了解了事件订阅/发布的eventbus整个流程,初探dapper ORM实现,并且简单 ...

  7. 如何编译和使用自定义Qt动态链接库 | how to build and use user-defined qt library

    本文首发于个人博客https://kezunlin.me/post/cf628dd8/,欢迎阅读! guide to build qt library and use in another proje ...

  8. 新闻实时分析系统 大数据Web可视化分析系统开发

    1.基于业务需求的WEB系统设计 2.下载Tomcat并创建Web工程并配置相关服务 下载tomcat,解压并启动tomcat服务. 1)新建web app项目 创建好之后的效果 2)对tomcat进 ...

  9. linux 正确的关机流程

    查看系统的使用状态 1.使用who命令查看在线用户. 2.使用netstat -a或ss -tnl查看网络状态: 3.使用ps -aux 查看后台运行的程序. 通过上述操作可以了解系统目前使用状态,从 ...

  10. 插槽在父组件和子组件间的使用(vue3.0推荐)

    子组件: 父组件: 插槽在父组件和子组件间的使用(vue3.0推荐):在外面加一个template模板