DCP-103: Make Sixovisible Back to All Problems

Medium Divide and Conquer > Dynamic Programming


You are given an integer N. You are allowed to remove zero or more digits from N such that the sum of the remaining digits is maximum and N becomes divisible by 6. You can remove digits from N till it has at least one digit. Input: ------ Input starts with an integer T (T ≤ 100) denoting the number of test cases. Each case contains an integer N (N > 0). Number of digits in N does not exceed 500. Output: ------- For each case, print the case number (starting from 1) and the sum of digits in resulting N. If no solution exists, print “Impossible” without the quotes. Sample Input ------------ 5 124 3552 99912137 82113 10 Sample Output ------------- Case 1: 6 Case 2: 15 Case 3: 30 Case 4: Impossible Case 5: 0


Problem Setter:

Ariful Hoque Maruf

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 2.00
Go 2.00
Java 2.00
JavaScript 2.00
Objective-C 2.00
Perl 2.00
PHP 2.00
Python 2.00
Python3 2.00
Ruby 2.00
VB.Net 2.00

Problem Stats

44/176

Solve/Submission

Ranking

# User Language Timing
01 sakib_muhit Cpp14 0.00s
02 feodorv C 0.00s
03 Ishrak Cpp 0.00s
04 haasib Cpp 0.00s
05 Tahmid Cpp14 0.00s
06 SakibAlamin Cpp14 0.00s
07 killer_knight Cpp 0.00s
08 prodipdatta7 Cpp14 0.01s
09 prateepm Cpp14 0.01s
10 Morass Cpp14 0.01s
11 umli Cpp 0.02s
12 robin_aust Cpp 0.07s
13 tariqiitju Cpp 0.12s
14 murad_al_wajed Cpp 0.14s
15 mh755628 Cpp 0.16s
16 _dipu Cpp14 0.17s
17 moinul_shaon Cpp14 0.27s
18 Sarwar05 Cpp 0.34s
19 dipta007 Cpp14 0.36s
20 alhelal_cse Cpp14 0.39s
21 dark_coderf Cpp14 0.40s
22 Nirjhor Cpp14 0.45s
23 rubabredwan Cpp14 0.46s
24 mamun4122 Cpp14 0.47s
25 sahedsohel Cpp14 0.49s
26 Pure_Protea Cpp14 0.49s
27 smjlord068 Cpp14 0.50s
28 Skyfall009 Cpp14 0.51s
29 gamerrishad Cpp14 0.52s
30 jahid_ict Cpp14 0.57s
31 raihatneloy Cpp14 0.58s
32 swapnil Cpp14 0.63s
33 Tanmoy1228 Cpp14 0.70s
34 SIR_MBSTU Cpp14 0.73s
35 froghramar Cpp14 1.19s
36 sohag_hstu Cpp14 1.35s
37 njrafi Cpp14 1.84s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support