DIV15 - Divisibility by 15
There is a string containing only decimal digit characters. The length of the string is between 1 and 1000. Using characters of the string, you have to construct the maximum number which divides by fifteen without remainder. Each character of the string may not be used more than once.
Input
First line of input contains an integer t (1 ≤ t ≤ 90), equal to the number of test cases. Then descriptions of t test cases follow.
Each testcase is described in a single line representing the source string.
Output
For each test case output one line with the decimal representation of the maximum number. Leading zeroes should be omitted. If no number can be constructed, output a single word “impossible”.
Example
Input: 1 02041 Output: 4200
hide comments
cjn2007:
2021-10-28 04:18:46
What a nightmare!
|
|
nadstratosfer:
2017-12-19 02:47:44
What a nightmare.. Spent 2.5 hours debugging to finally AC with the ugliest, dumbest code I've ever written.. Then again with 5245 out of 8381 submissions for this problem being WA's, elegance has to take the back seat. |
|
kira28:
2016-12-20 09:43:30
Some string manipulation and rest number theory!!! XD XD
|
|
rainy jain :
2016-05-21 08:02:26
@Ivan I'm getting SIGXFSZ . Please check id:16956224 |
|
Devashish Mathur:
2014-09-09 22:37:46
Please someone tell me which test case am i missing?
|
|
DEBAJIT DEY:
2013-12-07 08:16:58
what should be the output for 20
|
|
nadavishe:
2013-08-14 13:02:33
All time runtime error. But on my mashine tested many cases - and all is OK. Please help - my submission ID-9836707. Thanks |
|
wgjak47:
2013-07-29 06:54:27
ATTENTION!!DON'T USE gets() or fgets(),or you will get wrong answer.the input file must come from windows,but the judge computer is linux,they don't have the same line break..... |
|
UTSAV DEEP:
2013-06-08 21:33:17
always getting wrong ans
|
|
[Lakshman]:
2013-02-25 13:15:20
please any hint for this problem... |
Added by: | Ivan Metelsky |
Date: | 2005-08-25 |
Time limit: | 1.919s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: NODEJS PERL6 VB.NET |
Resource: | NEERC Western Subregion QF 2004 |