Sly Number
Time limit1sMemory limit128 MB
Determine whether a cyclic-convolution-based inverse (with entries restricted to {0,1,2}) exists for a given array modulo Q, essentially a search over polynomial ring inverses.
- Level
Medium6 of 10
- Topics
- Math, Brute force, Number theory
- Solved
- No attempts yet
Problem
A sly number is an array of integers, each taken from the set . For example, is a sly number with , , , and .
A sly number is called if and for every .
For two sly numbers and , the Star Multiplication produces an array of length defined by
The result is again an array of length , but it need not be a sly number (its entries may be larger than ). Results are reduced modulo a positive integer entrywise:
Given a sly number and a modulus , we look for an inverse sly number — that is, a sly number , whose entries are again from — such that
For each given and , decide only whether such an inverse sly number exists.
Input
The first line contains the number of test cases. Each test case consists of two lines. The first line contains two integers separated by a space: () and (). The second line contains the integers of the sly number , each from the set , separated by spaces.
Output
Print one line for each test case. If an inverse sly number exists, print A solution can be found. Otherwise, print No solution.
Hint
For the case , , , one possible inverse sly number is .