DCP-180: We Love Eight Back to All Problems

Medium Math > Number Theory


Sifat loves digits, yes you heard that right. But his thinking is really complex and some times he represents his questions also with so much complexity. Recently he found an amazing thing. See if an integer's last digit is divisible by 2, then the whole integer is divisible by 2. Again if sum of all the digits of an integer is divisible by 3, then the whole integer is divisible by 3. With this he came up with a great problem. Sifat will give you a very large integer, you have to tell him whether it is divisible by 8 or not. But here is a catch. Sifat won't give you the whole number. He will hide a digit and will replace that with ' A ' . Now when N will be divisible by 8, you have to tell him the value of ' A '. If there is multiple solution for ' A ' , tell the lowest number.The number can't have any leading zeroes. If there is no way the number can be divisible by 8, tell him " NO ". Remember you are a busy person, so you don't want to waste more than 0.5 seconds to answer per question asked by Sifat. Input: ------ Input starts with an integer **T (1 <= 20)**, denoting the number of test cases. Each case contains an string of length **N (8 ≤ N ≤ 10^7)**. The string should have no leading zeroes. **' A ' will be between 1 to ( n - 4 ) index.** Output: ------- For each line of output print "YES" if N is divisible by 8 else "NO" , without the ( " " ) sign. If N is divisible by 8, then print the value of ' A ' . **' A ' will appear only once in the string.** Sample Input ------------ 2 123A4128 91A45123 Sample Output ------------- YES 0 NO Hints ------------- For the first sample, A can be any value from 0 to 9 , so we print 0 as it is the lowest. The second sample can never be divisible by 8 for any value of A ( 0 - 9 ) .


Problem Setter:

Sifat Siddiqi Shishir

Please login to submit solution to this problem.

Problem Limits

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

Problem Stats

175/797

Solve/Submission

Ranking

# User Language Timing
01 prodipdatta7 Cpp14 0.00s
02 skmonir Cpp14 0.00s
03 fsshakkhor Cpp14 0.00s
04 imunir Cpp14 0.00s
05 Dariwala Cpp14 0.00s
06 ksohan Cpp14 0.00s
07 kamrulashraf Cpp14 0.00s
08 PKP_007 Cpp14 0.00s
09 rana_cse Cpp14 0.00s
10 Tanmoy_Datta Cpp14 0.00s
11 Jisancse Cpp14 0.00s
12 Gang_Of_Three_01 Cpp14 0.00s
13 nasif2587 Cpp14 0.00s
14 Masum_ice Cpp14 0.00s
15 shipon0142 Cpp14 0.00s
16 saurabh3240 Cpp14 0.00s
17 EWU_FatimaTasnim Cpp14 0.00s
18 MI47 Cpp14 0.00s
19 ehsan_sshuvo Cpp14 0.00s
20 sangshaptac Cpp14 0.00s
21 infinite_ary Cpp14 0.00s
22 limlim Cpp14 0.00s
23 ahmeddinar Cpp14 0.00s
24 rafsan_rana Cpp14 0.00s
25 RiponSaha Cpp14 0.00s
26 Code_Hunter Cpp14 0.00s
27 AlaminJust Cpp14 0.00s
28 burhan103335 Cpp14 0.00s
29 subhashis_cse Cpp14 0.00s
30 anik_JU Cpp14 0.00s
31 MazedRupok Cpp14 0.00s
32 nafiamahjabin Cpp14 0.00s
33 tahsin_siad27 Cpp14 0.00s
34 as_couple Cpp14 0.00s
35 IHR57 Cpp14 0.00s
36 Rizon_sunny Cpp14 0.00s
37 Dexter Cpp14 0.00s
38 prantacse14 Cpp14 0.00s
39 darkprinx Cpp14 0.00s
40 iu_refat_ict Cpp14 0.00s
41 Bidhan_Biswaas Cpp14 0.00s
42 Dragon_Curve Cpp14 0.00s
43 nafiz0080 Cpp14 0.00s
44 nurshuvo51 Cpp14 0.00s
45 Rajan_sust Cpp14 0.00s
46 shuvo_iu Cpp14 0.00s
47 nasir_32_15 Cpp14 0.00s
48 imAnik Cpp14 0.00s
49 rayhan50001 Cpp14 0.00s
50 moshiur_cse15 Cpp14 0.00s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support