time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
The little boy Nikita was given some cubes as a present. He decided to build a tower out of them.
Initially, the tower doesn't have any cubes. In one move, Nikita either puts exactly 11 cube on top of the tower or removes exactly 11 cube from the top of the tower. Is it possible that after n𝑛 moves, the resulting tower has exactly m𝑚 cubes?
Input
Each test contains multiple test cases. The first line of input contains a single integer t𝑡 (1≤t≤1001≤𝑡≤100) — the number of test cases. The description of the test cases follows.
The only line of each test case contains two integers n𝑛 and m𝑚 (1≤n,m≤1001≤𝑛,𝑚≤100).
Output
For each test case, output "Yes" (without quotes) if Nikita can obtain a tower with m𝑚 cubes, and "No" (without quotes) otherwise.
You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.
Example
input
Copy
3
3 3
2 4
5 3
output
Copy
Yes No Yes
Note
In the first test case, Nikita can put 11 cube on top of the tower 33 times in a row, so the answer is "Yes".
In the second test case, Nikita can only end up with either a tower with no blocks or a tower with 22 blocks, so the answer is "No".
解题说明:此题是一道模拟题,由于每次要么减去1要么加上1,为了确保最后正好为m个,首先确保个数不少于m,其次需要保证差值正好为2的整数倍。
#include<stdio.h>
int main()
{
int t, i, n, m;
scanf("%d", &t);
for (i = 0; i < t; i++)
{
scanf("%d %d", &n, &m);
if (n < m)
{
printf("No\n");
}
else if ((n - m) % 2 != 0)
{
printf("No\n");
}
else
{
printf("Yes\n");
}
}
return 0;
}