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 ...
随机推荐
- mysql出现ERROR 1819 (HY000)的解决方法
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements, 出现这个问题怎么办? 为了加强安 ...
- ACM-ICPC 2018 I. Characters with Hash
I. Characters with Hash Mur loves hash algorithm, and he sometimes encrypt another one's name, and c ...
- npm报错:无法加载文件 D:\nodejs\node_global\webpack.ps1,因为在此系统上禁止运行脚本
npm报错 在 windows终端输入 vue init webpack app, 创建一个名为 app 的 Vue 项目时报错如下: 无法加载文件 D:\nodejs\node_global\web ...
- 堡垒机的核心武器:WebSSH录像实现
WebSSH终端录像的实现终于来了 前边写了两篇文章『Asciinema:你的所有操作都将被录制』和『Asciinema文章勘误及Web端使用介绍』深入介绍了终端录制工具Asciinema,我们已经可 ...
- 领扣(LeetCode)两个数组的交集II 个人题解
给定两个数组,编写一个函数来计算它们的交集. 示例 1: 输入: nums1 = [1,2,2,1], nums2 = [2,2] 输出: [2,2] 示例 2: 输入: nums1 = [4,9,5 ...
- 使用ndk交叉编译android各平台版本的第三方库
只要弄明白了ndk-bundle的目录结构,交叉编译的基本原理就可以自行编写脚本去编译了.从仓库拿下代码包后,一般在linux平台下编译当前平台使用的库,只要使用其自动配置脚本configure进行平 ...
- 带你涨姿势的认识一下 Kafka 消费者
之前我们介绍过了 Kafka 整体架构,Kafka 生产者,Kafka 生产的消息最终流向哪里呢?当然是需要消费了,要不只产生一系列数据没有任何作用啊,如果把 Kafka 比作餐厅的话,那么生产者就是 ...
- vscode在终端运行脚本时出现“因为在此系统上禁止运行脚本”
首先关闭vscode,再以管理员的身份运行vscode,然后打开终端执行: get-ExecutionPolicy,显示的是Restricted,表示状态是禁止的; 再执行:set-Execution ...
- 【2018寒假集训Day 7】【最短路径】三种算法的模板
Luogu单源最短路径模版题 dijkstra #include<cstdio> #include<vector> using namespace std; const int ...
- python爬虫项目-一见倾心壁纸
方法1 import re import urllib import urllib.request def getHtml(url): page = urllib.request.urlopen(ur ...