题目:魔法棒##

题意:可以对一个正数进行变换,如果数字是偶数,那么它可以变成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的更多相关文章

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

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

  3. 【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 ...

  4. Educational Codeforces Round 76 (Rated for Div. 2)

    传送门 A. Two Rival Students 签到. Code /* * Author: heyuhhh * Created Time: 2019/11/13 22:37:26 */ #incl ...

  5. CF Educational Round 78 (Div2)题解报告A~E

    CF Educational Round 78 (Div2)题解报告A~E A:Two Rival Students​ 依题意模拟即可 #include<bits/stdc++.h> us ...

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

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

  8. Python魔术方法-Magic Method

    介绍 在Python中,所有以"__"双下划线包起来的方法,都统称为"Magic Method",例如类的初始化方法 __init__ ,Python中所有的魔 ...

  9. 【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 ...

随机推荐

  1. js数组方法大全(下)

    # js数组方法大全(下) 记录一下整理的js数组方法,免得每次要找方法都找不到.图片有点多,注意流量,嘻嘻! 本期分享 forEach() map() filer() every() some() ...

  2. 小白学 Python(23):Excel 基础操作(上)

    人生苦短,我选Python 前文传送门 小白学 Python(1):开篇 小白学 Python(2):基础数据类型(上) 小白学 Python(3):基础数据类型(下) 小白学 Python(4):变 ...

  3. awk 实用案例介绍

    awk 简介 • awk是 3 个姓氏的首字母,代表该语言的 3 个作者 • awk的版本有很多,包括: 旧版 awk,新版 awk(nawk), GNUawk(gawk)等 • awk程序有 awk ...

  4. Vue学习笔记:Vue组件的核心概念(下)

    1.双向绑定和单向数据流: 本质上还是单向数据流 视图<——>数据 v-model:仅仅是一个简写,用更少代码去实现功能. 自定义事件 .sync 修饰符 2.虚拟DOM及KEY属性作用 ...

  5. Cache地址映射

    原理:程序访问局部性         在较短时间内由程序产生的地址往往集中在存储器逻辑地址空间的很小范围内         时间:在一小段时间内,最近被访问过的程序和数据很可能再次被访问       ...

  6. dubbo分布式Service不可以创建Error creating bean with name 'XXXXXX'

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demoService' ...

  7. nyoj 283-对称排序 (sort)

    283-对称排序 内存限制:64MB 时间限制:1000ms 特判: No 通过数:2 提交数:4 难度:1 题目描述: In your job at Albatross Circus Managem ...

  8. 领扣(LeetCode)找树左下角的值 个人题解

    给定一个二叉树,在树的最后一行找到最左边的值. 示例 1: 输入: 2 / \ 1 3 输出: 1 示例 2: 输入: 1 / \ 2 3 / / \ 4 5 6 / 7 输出: 7 注意: 您可以假 ...

  9. 使用Java窗口程序执行输入的任何cmd命令

    利用Java窗口程序来执行用输入的任何命令 实现效果: Java桌面窗口,输入框.按钮,当输入框被输入命令的时候,点击按钮执行命令! 实现代码 package com.remote.remote.ag ...

  10. nexus https proxy