B. Magic Stick
题目:魔法棒##
题意:可以对一个正数进行变换,如果数字是偶数,那么它可以变成3 * a / 2
如果这个数大于1,那么它可以变成a - 1
有两个数x和y,询问是否可以通过这些操作从x变成y,输出YES或NO
分析,1不能通过变换变成其它任何数字,2可以变成3或者1,3只能变成2
分类讨论
如果x > 3,x可以变成任何数字
分析x <= 3,如果x == 3,那么3只能变成2, 再从2变成3或者1,因此y必须小于等于3
如果x == 2,y必须小于等于3
如果x == 1,y必须等于1
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int INF = 0x3f3f3f3f;
int main()
{
int t;
scanf("%d", &t);
int x, y;
while (t--)
{
scanf("%d%d", &x, &y);
//从x变换为y
//x > 3那么可以变成任何数字
if (x > 3)
{
puts("YES");
}
else if (x == 1)
{
if (y == 1)
puts("YES");
else
puts("NO");
}
else if (x <= 3)
{
if (y <= 3)
{
puts("YES");
}
else {
puts("NO");
}
}
}
return 0;
}
B. Magic Stick的更多相关文章
- Educational Codeforces Round 76 (Rated for Div. 2) B. Magic Stick 水题
B. Magic Stick Recently Petya walked in the forest and found a magic stick. Since Petya really likes ...
- Educational Codeforces Round 76 (Rated for Div. 2) B. Magic Stick
Recently Petya walked in the forest and found a magic stick. Since Petya really likes numbers, the f ...
- 【CF1257B】Magic Stick【思维】
题意:每次可以对a进行两种操作,1:如果是偶数,则变成3*a/2:2:变成a-1 显然当a=1时,b只能为1 a=2或3时,b只能为123 a>3时,b可以为任意数 代码: #include&l ...
- Educational Codeforces Round 76 (Rated for Div. 2)
传送门 A. Two Rival Students 签到. Code /* * Author: heyuhhh * Created Time: 2019/11/13 22:37:26 */ #incl ...
- CF Educational Round 78 (Div2)题解报告A~E
CF Educational Round 78 (Div2)题解报告A~E A:Two Rival Students 依题意模拟即可 #include<bits/stdc++.h> us ...
- Codeforces CF#628 Education 8 D. Magic Numbers
D. Magic Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- [8.3] Magic Index
A magic index in an array A[0...n-1] is defined to be an index such that A[i] = i. Given a sorted ar ...
- Python魔术方法-Magic Method
介绍 在Python中,所有以"__"双下划线包起来的方法,都统称为"Magic Method",例如类的初始化方法 __init__ ,Python中所有的魔 ...
- 【Codeforces717F】Heroes of Making Magic III 线段树 + 找规律
F. Heroes of Making Magic III time limit per test:3 seconds memory limit per test:256 megabytes inpu ...
随机推荐
- centos6官网镜像dvd1和dvd2的解释
- [ASP.NET Core 3框架揭秘] 文件系统[2]:总体设计
在<抽象的"文件系统">中,我们通过几个简单的实例演示从编程的角度对文件系统做了初步的体验,接下来我们继续从设计的角度来进一步认识它.这个抽象的文件系统以目录的形式来组 ...
- hdu 1233 (prim,最小生成树) 还是畅通工程
还是畅通工程Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- hdu 5901 Count primes (meisell-Lehmer)
Count primes Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...
- FB力挺的Pytorch深度学习 书本来了
获得 fb首席科学家力挺的 pytorch教程 发布啦, 看截图 
转载出处:https://github.com/Trinea/android-open-project 第一部分 个性化控件(View) 主要介绍那些不错个性化的 View,包括 ListView.A ...
- Spring中常见的设计模式——工厂模式
一.简单工厂模式 简单工厂模式(Simple Factory Pattern)由一个工厂对象决定创建哪一种产品类的实例,简单工厂模式适用于工厂类负责创建对象较少的情况,且客户端只需要传入工厂类的参数, ...
- 2019-10-16:渗透测试,基础学习,burpsuit笔记
maccms10后门分析下载网址,是假官网http://www.maccmsv10.com/download.htmlMaccms10基于php+mysql的maccms,是苹果的内容管理,方便使用, ...