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

172/793

Solve/Submission

Ranking

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

Your feedback is our precious!



Or call +88 02 9853138 for support