Back to problems Sign in to unlock
Codeforces
Easy
Arrays
Strings
Math
Roma and Lucky Numbers
Count how many numbers in a list contain only lucky digits 4 and 7.
Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.
Lucky Numbers
gfgProblem Statement
Problem
Roma considers a number lucky if every digit of the number is either 4 or 7.
You are given a list of integers. Count how many of them are lucky.
For each number, inspect its decimal digits and decide whether all digits are lucky digits.
Input Format
- The first line contains an integer
n— the number of integers. - The second line contains
nspace-separated integers.
Output Format
- Print a single integer: the count of lucky numbers in the list.
Constraints
1 <= n <= 1000- Each number is a positive integer that fits in 32-bit signed integer range.
Hints
- Check digits one by one using division and remainder.
- A number is lucky only if every digit is either
4or7.
Input Format
- The first line contains an integer
n. - The second line contains
nintegers.
Output Format
Print one integer — the number of lucky integers.
Constraints
1 <= n <= 1000- Numbers are positive integers within 32-bit signed integer range.
Examples
Sample cases returned by the problem API.
Example 1
Input
5 4 7 447 123 774
Output
4
Explanation
The numbers 4, 7, 447, and 774 are lucky. The number 123 is not.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.
Guided hints
Editorial and discussion links
Concept map and variants
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.