欢迎光临散文网 会员登陆 & 注册

CF 1814A - Coins

2023-07-20 15:12 作者:您是打尖儿还是住店呢  | 我要投稿

In Berland, there are two types of coins, having denominations of 2 and k burles.

Your task is to determine whether it is possible to represent n burles in coins, i. e. whether there exist non-negative integers x and y such that 2⋅x+k⋅y=n.

Input

The first line contains a single integer t (1≤t≤104) — the number of test cases.

The only line of each test case contains two integers n and k (1≤k≤n≤1018; k≠2).

Output

For each test case, print YES if it is possible to represent n burles in coins; otherwise, print NO. You may print each letter in any case(YES, yes, Yes will all be recognized as positive answer, NO, no and nO will all be recognized as negative answer).

-------------------------------------------

在贝尔兰,有两种硬币,面值分别为 2 伯勒和 k 伯勒。

你的任务是确定是否可以用硬币 i 来表示 n 个 burles。 e. 是否存在非负整数 x 和 y 使得 2⋅x+k⋅y=n。

输入

第一行包含一个整数 t (1≤t≤104) — 测试用例的数量。

每个测试用例的唯一行包含两个整数n和k(1≤k≤n≤1018;k≠2)。

输出

对于每个测试用例,如果可以用硬币表示n个burles,则打印YES; 否则,打印NO。 您可以在任何情况下打印每个字母(YES、yes、Yes 都将被识别为肯定答案,NO、no 和 nO 都将被识别为否定答案)。

----------------------------------------------

发现了,我就只能做做AB类的题目,C的都差很多,遥遥无期的刷题路啊。。。。

这里面只有k是偶数,n为奇数的时候才组成不了,其他都可以。


CF 1814A - Coins的评论 (共 条)

分享到微博请遵守国家法律