题目链接:https://codeforces.com/contest/1477/problem/A
A. Nezzar and Board
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output
nn distinct integers x1,x2,…,xnx1,x2,…,xn are written on the board. Nezzar can perform the following operation multiple times.
- Select two integers x,yx,y (not necessarily distinct) on the board, and write down 2x−y2x−y. Note that you don't remove selected numbers.
Now, Nezzar wonders if it is possible to have his favorite number kk on the board after applying above operation multiple times.
Input
The first line contains a single integer tt (1≤t≤1051≤t≤105) — the number of test cases.
The first line of each test case contains two integers n,kn,k (2≤n≤2⋅1052≤n≤2⋅105, −1018≤k≤1018−1018≤k≤1018).<