Lucky SumProblem code: LUCKY3 |
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 also use term "lucky sum". Lucky sum is an operation between two integers. Let the first integer is A, A[i] equals i-th digit of A (0-base numeration, from right to left) and the second integer is B, B[i] equals to i-th digit of B. Then the lucky sum of A and B is equal to C, C[i] = max(A[i], B[i]). If i is greater than or equal to size of integer, the i-th digit is equal to 0. For example, the lucky sum of 47 and 729 equals 749, the lucky sum of 74 and 92 and 477 equals 497.
Chef has an array W of integers. Find a number of non-empty subsequences of W such that the lucky sum of integers in that subsequences is a lucky number.
Subsequence of W is created by erasing some number (probably zero) elements from W.
Input
First line contains one number T, number of test cases. Each test is formed as follows: first line contains integer n - number of integers in W, next line contains n integers - array W for corresponding test.
Output
For each T test cases print one integer - result for the corresponding test.
Constraints
1 <= T <= 10
1 <= n <= 50
1 <= Wi < 10^9
Example
Input: 2 2 4 7 3 43 87 44 Output: 3 2
| Author: | witua |
| Date Added: | 21-11-2011 |
| Time Limit: | 5 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

cudn't get whatz meant by
can u pls explain the
I doubt the problem
@kp25 @sravansai please read
@zjut_dd If W = {4, 4}, there
does subsequence only contain
@kewljerk Read the problem
thanx admin!
can the answer exceed integer
I mean for case like 1 50 7 7
Statement does not say
4 and 7 gives ans 3 but it
@goelrinku Read the problem
Admin, is the answer the
@admins: Shouldn't the answer
@sai16vicky repetation is
@mr777 The sample cases in
I think there's an issue. The
The lucky sum of the sequence
what is meaning
Imagine that you have some
@mak_zed The definition of
"If i is greater than or
@umangkedia It means that
where is this problem added