Ciel Numbers II
All submissions for this problem are available.
Recently, chef Ciel often hears about 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.
Ciel decides to make Ciel numbers.
As you know, Ciel likes the digit 8 very much.
And then, Ciel likes the digits 5 and 3.
So Ciel defines Ciel numbers as the positive integers k such that d(k, 8) ≥ d(k, 5) ≥ d(k, 3) and d(k, i) = 0 for all i = 0, 1, 2, 4, 6, 7, 9,
where d(k, i) denotes the number of the digit i in the decimal representation of the integer k.
For example, the first few Ciel numbers are 8, 58, 85, 88, 358, 385, 538, 583, 588, 835, 853, 858, 885, 888, ....
Ciel's restaurant has N menus.
And Ciel want to know how many menus have Ciel numbers as their price.
Your task is to find it.
The first line contains an integer N.
Then N lines follow.
Each line has the name Si of the menu and its price Pi separated by a single space.
Print the number of menus whose prices are one of Ciel numbers.
1 ≤ N ≤ 1000
1 ≤ |Si| ≤ 100, where |Si| denotes the length of Si
Each letter of Si is either an alphabetical letter or a digit or a single quotation mark or a space.
1 ≤ Pi < 1000000 (106)
Pi contains no leading zeros.
6 milk 58 Ciel's Drink 80 The curry 2nd edition 888888 rice omelet 85855 unagi 1 The first and last letters can be a space 358
58 and 888888 and 358 are Ciel numbers.
80 and 85855 and 1 are not Ciel numbers.
Different operating systems have different ways of representing a newline; do not assume one particular way will be used.
|Tags||cook20, easy, laycurse|
|Time Limit:||0.621212 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions