Ahn Subin Number
Time limit0.5sMemory limit128 MB
For each N up to 100,000,000, find a multiple of N whose decimal digit sum is odd, or print -1 if none exists.
- Level
Medium6 of 10
- Topics
- Number theory, Math
- Solved
- No attempts yet
Problem
The digit sum of a number is the sum of its digits when written in base 10. For example, the digit sum of 1093 is .
A positive integer whose digit sum is even is called a Subin number. A positive integer that is not a Subin number is called an Ahn Subin number.
Given a positive integer , write a program that checks whether a multiple of is an Ahn Subin number. If one exists, print any one of them.
Input
The first line contains the number of test cases ().
Each of the next lines contains one test case, an integer ().
Output
For each test case, print one line.
- If no multiple of is an Ahn Subin number, print
-1. - If a multiple of is an Ahn Subin number, print any one Ahn Subin number among those multiples that is at most .
For every positive integer up to 100,000,000, if a multiple of is an Ahn Subin number, then an Ahn Subin number at most is guaranteed to exist.