CF986F.Oppa Funcan Style Remastered

NOI/NOI+/CTSC

通过率:0%

时间限制:5.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Surely you have seen insane videos by South Korean rapper PSY, such as "Gangnam Style", "Gentleman" and "Daddy". You might also hear that PSY has been recording video "Oppa Funcan Style" two years ago (unfortunately we couldn't find it on the internet). We will remind you what this hit looked like (you can find original description here):

On the ground there are nn platforms, which are numbered with integers from 11 to nn, on ii-th platform there is a dancer with number ii. Further, every second all the dancers standing on the platform with number ii jump to the platform with the number f(i)f(i). The moving rule ff is selected in advance and is not changed throughout the clip.

The duration of the clip was kk seconds and the rule ff was chosen in such a way that after kk seconds all dancers were in their initial positions (i.e. the ii-th dancer stood on the platform with the number ii). That allowed to loop the clip and collect even more likes.

PSY knows that enhanced versions of old artworks become more and more popular every day. So he decided to release a remastered-version of his video.

In his case "enhanced version" means even more insanity, so the number of platforms can be up to 101810^{18}! But the video director said that if some dancer stays on the same platform all the time, then the viewer will get bored and will turn off the video immediately. Therefore, for all xx from 11 to nn f(x)≠xf(x) \neq x must hold.

Big part of classic video's success was in that looping, so in the remastered version all dancers should return to their initial positions in the end of the clip as well.

PSY hasn't decided on the exact number of platforms and video duration yet, so he asks you to check if there is a good rule ff for different options.

你一定看过韩国说唱歌手PSY那些疯狂的视频,例如《江南Style》《绅士》和《爸爸》。你可能也听说过,PSY早在两年前就已开始录制新视频《欧巴Funcan Style》(遗憾的是,我们未能在网上找到该视频)。下面我们为你回顾一下这支热门视频的设定(原始描述可参见此处):

地面上有 nn 个平台,编号为 11 至 nn;第 ii 个平台上站着编号为 ii 的舞者。此后,每过一秒,所有站在编号为 ii 的平台上的舞者都会跳到编号为 f(i)f(i) 的平台上。移动规则 ff 在视频拍摄前即已选定,并在整个视频播放过程中保持不变。

该视频时长为 kk 秒,且规则 ff 的选取方式保证:经过 kk 秒后,所有舞者均回到初始位置(即编号为 ii 的舞者重新站回编号为 ii 的平台)。这使得视频可以无缝循环播放,从而收获更多点赞。

PSY深知,经典作品的增强版正日益受到追捧。因此,他决定推出该视频的重制版。

对他而言,“增强版”意味着更加疯狂——平台数量最多可达 101810^{18}!但视频导演指出:若某位舞者全程始终停留在同一平台上,则观众会感到乏味并立即关闭视频。因此,对所有 x∈{1,2,…,n}x \in \{1, 2, \dots, n\},必须满足 f(x)≠xf(x) \neq x。

原版视频广受欢迎的一大原因正是其循环特性,因此在重制版中,所有舞者也必须在视频结束时回到各自的初始位置。

PSY 尚未最终确定平台数量与视频时长,因此他请你帮忙验证:对于各种参数选项,是否存在一个满足要求的规则 ff。

输入格式

In the first line of input there is one integer tt (1≤t≤1041 \le t \le 10^{4}) — the number of options for nn and kk to check.

In the next tt lines the options are given: each option is described with two integers nn and kk (1≤n≤10181 \le n \le 10^{18}, 1≤k≤10151 \le k \le 10^{15}) — the number of dancers and the duration in seconds.

It is guaranteed that the number of different values of kk in one test is not greater than 5050.

输入的第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^{4})—— 表示需要检验的 nn 和 kk 的选项数量。

接下来 tt 行给出这些选项:每行用两个整数 nn 和 kk(1≤n≤10181 \le n \le 10^{18},1≤k≤10151 \le k \le 10^{15})描述一个选项,分别表示舞者人数和持续时间(单位:秒)。

保证在一个测试用例中,不同的 kk 值的个数不超过 5050。

输出格式

Print tt lines. If the ii-th option of the video is feasible, print "YES" (without quotes) in ii-th line, otherwise print "NO" (without quotes).

输出 tt 行。如果视频的第 ii 个选项可行,则在第 ii 行输出 "YES"(不带引号),否则输出 "NO"(不带引号)。

输入输出样例

  • 输入#1

    3
    7 7
    3 8
    5 6

    输出#1

    YES
    NO
    YES

输入解题思路,AI测评打分。不知道怎么写?

首页