diff options
Diffstat (limited to 'NearlyLuckyNumber/main.cpp')
| -rw-r--r-- | NearlyLuckyNumber/main.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/NearlyLuckyNumber/main.cpp b/NearlyLuckyNumber/main.cpp new file mode 100644 index 0000000..d807b1a --- /dev/null +++ b/NearlyLuckyNumber/main.cpp @@ -0,0 +1,31 @@ +#include<bits/stdc++.h> + +using namespace std; + +bool isLucky(string s) { + for(int i = 0; i < s.size(); i++) { + if(s[i] != '4' && s[i] != '7') { + return false; + } + } + return true; +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + long long n; + cin >> n; + string s = to_string(n); + int cnt = 0; + for(auto ch : s) { + if(ch == '4' || ch == '7') { + cnt ++; + } + } + if(isLucky(to_string(cnt))) { + cout << "YES"; + } else { + cout << "NO"; + } +} |
