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 ...
随机推荐
- Jetpack Compse 实战 —— 全新的开发体验
公众号回复 Compose 获取安装包 项目地址: Wanandroid-Compose 经过前段时间的 Android Dev Summit ,相信你已经大概了解了 Jetpack Compose ...
- 深入理解计算机系统 第八章 异常控制流 Part1 第二遍
第二遍读这本书,每周花两到三小时时间,能读多少读多少(这次看了第 500~507 页,共 8 页) 第一遍对应笔记链接 https://www.cnblogs.com/stone94/p/101651 ...
- mybatis什么时候必须指定jdbcType
#{property,javaType=int,jdbcType=NUMERIC}如果一个列允许 null 值,并且会传递值 null 的参数,就必须要指定 JDBC Type
- ThinkPHP v5.1.x POP 链分析
环境:MacOS 10.13 MAMAP Prophp 7.0.33 + xdebugVisual Studio Code前言我所理解的 POP Chain:利用魔术方法并巧妙构造特殊属性调用一系列函 ...
- hdu 1754 I Hate It (线段树、单点更新)(PS:ios::sync_with_stdio(false)可以加快cin、cout的读取写出速度)
I Hate ItTime Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- deepin MySQL 安装以及编码格式的修改utf-8
deepin MySQL 安装以及编码格式的修改utf-8: 1.sudo apt-get install mysql-server mysql-client 2.sudo mysql -u root ...
- 如何打造一款m3u8视频爬虫
0.前言 m3u8是一种很常见的网页视频播放器的视频源,比如说中国大学MOOC中课程就是使用了该种视频格式. 随便打开一门课程,就可以发现在网络请求中存在一个m3u8的文件,在preview中预览,它 ...
- Install gitlab
yum install -y curl policycoreutils-python openssh-server postfix wget wget https://mirrors.tuna.tsi ...
- 📈📈📈📈📈iOS 图表框架 AAChartKit ---强大的高颜值数据可视化图表框架,支持柱状图、条形图、折线图、曲线图、折线填充图、曲线填充图、气泡图、扇形图、环形图、散点图、雷达图、混合图
English Document
- scikit-learn网格搜索来进行高效的参数调优
内容概要¶ 如何使用K折交叉验证来搜索最优调节参数 如何让搜索参数的流程更加高效 如何一次性的搜索多个调节参数 在进行真正的预测之前,如何对调节参数进行处理 如何削减该过程的计算代价 1. K折交叉验 ...