diff options
| author | Omar Magdy <omar.professional8777@gmail.com> | 2022-06-25 18:32:00 +0200 |
|---|---|---|
| committer | Omar Magdy <omar.professional8777@gmail.com> | 2022-06-25 18:32:00 +0200 |
| commit | 7c3f32fab3b1a9d628d6856e7a923eb3c3b1ce5f (patch) | |
| tree | 484c58be6bc4ceadf35010ed8b81854994903503 /NearlyLuckyNumber/main.cpp | |
| parent | a0a07a438b6804fdca0e18b2d626ceedb982611c (diff) | |
| download | competitive-programming-7c3f32fab3b1a9d628d6856e7a923eb3c3b1ce5f.tar.xz competitive-programming-7c3f32fab3b1a9d628d6856e7a923eb3c3b1ce5f.zip | |
Solved a couple of problems from codechef and codeforces
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"; + } +} |
