m이 n 이하일 때 x^2+y^2≡a, xy≡b (mod m)를 만족하는 정수 x, y가 존재하는 (a,b,m)의 개수를 센다.
어려움9정수론수학동적 계획법아직 제출이 없습니다시간 제한2초메모리 제한512 MBThe conclusion of Hilbert's tenth problem shows that it is impossible to design an algorithm to find all integer solutions of an arbitrary system of equations. But for some simple equations, is is still easily doable.
For example, how do we check if there exist two integers x and y which satisfy x2+y2=a and xy=b? We can calculate x+y=±a+2b and x−y=±a−2b, and then check if both x and y could be integers.
Rikka thinks this task is too simple, and she wants to make it look harder. Rikka knows that sometimes, if you consider an equality modulo m, the problem becomes different. So, she wants to do the same thing to this problem.
Let us call a tuple (a,b,m) (0≤a,b<m) valid if and only if there exist two integers x and y which satisfy x2+y2≡a(modm) and xy≡b(modm). After giving you a positive integer n, Rikka wants you to calculate the number of valid tuples (a,b,m) with m≤n. As this number may be rather large, calculate it modulo 998,244,353.
The first line contains a single integer t (1≤t≤105), the number of test cases.
Each test case is given on a separate line containing a single integer n (1≤n≤107).
For each test case, output a single line with a single integer: the number of valid tuples modulo 998,244,353.