A True Expression
InterviewTime limit2sMemory limit1024 MB
Given an expression A ? B = C with up to 1000-digit integers, list every base from 2 to 10 in which the equation holds.
- Level
Easy3 of 10
- Topics
- Brute force, Implementation, Math
- Solved
- No attempts yet
문제
Many statements look false at first glance. For example, looks wrong, but in base the equation becomes true: .
You are given an expression , where , , and are non-negative integers, and is one of the symbols for addition, subtraction, or multiplication. List every base from to in which the equation is true. Recall that base uses only the digits to .
입력
The input is one line containing the expression . The symbol is one of , , or . The parts of the expression are separated by single spaces. Each of , , and has at most 1000 digits. Every number consists of the digits 0 to 9 and has no redundant leading zeros.
출력
Print the number of suitable bases on the first line. On the second line, print the bases in increasing order.