F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Digit-Sum

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 1836    Accepted Submission(s): 656


Problem Description
Let $S(N)$ be digit-sum of $N$, i.e $S(109)=10,S(6)=6$.

If two positive integers $a,b$ are given, find the least positive integer $n$ satisfying the condition $a\times S(n)=b\times S(2n)$.

If there is no such number then output 0.
 

Input
The first line contains the number of test caces $T(T\leq 10)$.
The next $T$ lines contain two positive integers $a,b(0<a,b<101)$.
 

Output
Output the answer in a new line for each test case.
 

Sample Input
3 2 1 4 1 3 4
 

Sample Output
1 0 55899
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 16:53:45, Gzip enabled