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

Multiple

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1284    Accepted Submission(s): 363


Problem Description
  Given a positive integer N, you¨re to solve the following problem:
  Find a positive multiple of N, says M, that contains minimal number of different digits in base-K notation. If there¨re several solutions, you should output the numerical smallest one. By saying numerical smallest one, we compar their numerical value, so 0xAhex < 11dec.
  You may assume that 1 <= N <= 104 and 2 <= K <= 10.
 

Input
  There¨re several (less than 50) test cases, one case per line.
  For each test case, there is a line with two integers separated by a single space, N and K.
  Please process until EOF (End Of File).
 

Output
  For each test case, you should print a single integer one line, representing M in base-K notation,the answer.
 

Sample Input
10 8 2 3 7 5
 

Sample Output
2222 2 111111
 

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-04-19 22:43:24, Gzip enabled