Lucky LongProblem code: LUCKY5 |
All submissions for this problem are available.
Chef loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Chef has a positive integer N. He can apply any of the following operations as many times as he want in any order:
- Add 1 to the number N.
- Take some digit of N and replace it by any non-zero digit.
- Add any non-zero leading digit to N.
Find the minimum number of operations that is needed for changing N to the lucky number.
Input
The first line contains a single positive integer T, the number of test cases. T test cases follow. The only line of each test case contains a positive integer N without leading zeros.
Output
For each T test cases print one integer, the minimum number of operations that is needed for changing N to the lucky number.
Constraints
1 ? T ? 10
1 ? N < 10100000
Example
Input: 3 25 46 99 Output: 2 1 2
| Author: | witua |
| Date Added: | 5-12-2011 |
| Time Limit: | 2 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC |
Comments

Fetching successful submissions

I am little confused with the
I cannot understand the 2nd
phantom11: no, you choose
I am not clear on the 3rd
I think so it means 10^x
can anyone help me about what
I think 3rd step means we can
Can anyone please elaborate
Please re-stat this
To all: First operation: add
@admin--please clarify the
@psingh871: Third operation
@admin Is it mandatory to use
No, it's not.
what do you mean by take some
@login_test: Actually, digit
@witally_adm: Thank You! I
The changed number(which is
does the first and last
@tru3liar: no
@prateekk91: Your test is
could i have any test case
It is giving wrong answer,
one of my comment here is
Y U NO ACCEPT C/C++ SOLUTION?
I do not find any test case
What is the minimum number of
@marcusflint: it is 0.
@admin.. please give me one
@admin It seems that some
Awesome Q!!!!
Please clearify "Take some
if n is 10^99999 then how am
@prashant170392 Please don't
@fura2 You CANNOT assume the
@poojits It counted as three
@Tool Please don't write any
@daryllopes89 Please think it
@munzirbm About the 3rd
@rushilpaul Read Rules:
That definitely wasn't a tip.
is "400" a lucky number?
@professor: no, it is not.
max N is 10^100000, is it
in a turn, 3 operations(may
@darkdiver: no, 004 is not a
@flareneos: I did the same
Yes, there is definitely
@admin Can any operation be
004->lucky number 2 steps or
@rushilpaul Yeah, these tasks
Something must be wrong with
@admin I feel that these
@admin... seriously there is
neil_812: what did you do
Easy and a good one!
@rushilpaul I used Python and
@admin is there any special
@admin code works well in my
same problem as kp
same as kp25.. :((
Is the range given for N with
if someone entered 004 do we
@codechef this is very sad
@c2tarun a positive integer N
can i use only one of those
What are problems with
Problem with input.
This was so irritating.
what is problem with
is the minimum count within
@admin : plz clarify 23 -->
@bodmas: yes, it is.
i did the question with just
can anyone tell why i am
hi there..... can anyone
How the minimum count be
@admin what if the number
@admin can we have test cases
i meant N > 100000
can we enter numbers which
@admin, Thanks for the last
@bodmas: Yes, I understand
@abhipranay: the output for
frnz solve it using java its
Why do i get the Runtime
Admins, Your problem
@krunalmodi: You are right. I
what r the 3 conditions mean