![]() |
||||||||||
|
||||||||||
Binary StringTime Limit: 2000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 916 Accepted Submission(s): 311 Problem Description Give you a binary string, you can add some 1s or 0s at any places of the string. Then the result divide by K, and the remainder should be zero. Please print string of the result, if there are more, print the one with the smallest length, if still more, print the smallest lexicographical one. If there is no such result print impossible. Input No more than 10 test cases. For each test case first line is a nonempty binary string whose length is no more than 20 and without leading zeros. Next line is an integer K(1 <= K <= 200). Output Print the result described above. Sample Input
Sample Output
Source | ||||||||||
|