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 | |
| 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')
| -rw-r--r-- | NearlyLuckyNumber/inp | 0 | ||||
| -rwxr-xr-x | NearlyLuckyNumber/main | bin | 0 -> 25264 bytes | |||
| -rw-r--r-- | NearlyLuckyNumber/main.cpp | 31 | ||||
| -rw-r--r-- | NearlyLuckyNumber/main_input0.txt | 1 | ||||
| -rw-r--r-- | NearlyLuckyNumber/main_input1.txt | 1 | ||||
| -rw-r--r-- | NearlyLuckyNumber/main_input2.txt | 1 | ||||
| -rw-r--r-- | NearlyLuckyNumber/main_output0.txt | 1 | ||||
| -rw-r--r-- | NearlyLuckyNumber/main_output1.txt | 1 | ||||
| -rw-r--r-- | NearlyLuckyNumber/main_output2.txt | 1 |
9 files changed, 37 insertions, 0 deletions
diff --git a/NearlyLuckyNumber/inp b/NearlyLuckyNumber/inp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/NearlyLuckyNumber/inp diff --git a/NearlyLuckyNumber/main b/NearlyLuckyNumber/main Binary files differnew file mode 100755 index 0000000..508d7ae --- /dev/null +++ b/NearlyLuckyNumber/main 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"; + } +} diff --git a/NearlyLuckyNumber/main_input0.txt b/NearlyLuckyNumber/main_input0.txt new file mode 100644 index 0000000..86b9da8 --- /dev/null +++ b/NearlyLuckyNumber/main_input0.txt @@ -0,0 +1 @@ +40047 diff --git a/NearlyLuckyNumber/main_input1.txt b/NearlyLuckyNumber/main_input1.txt new file mode 100644 index 0000000..92660b6 --- /dev/null +++ b/NearlyLuckyNumber/main_input1.txt @@ -0,0 +1 @@ +7747774 diff --git a/NearlyLuckyNumber/main_input2.txt b/NearlyLuckyNumber/main_input2.txt new file mode 100644 index 0000000..c9a4149 --- /dev/null +++ b/NearlyLuckyNumber/main_input2.txt @@ -0,0 +1 @@ +1000000000000000000 diff --git a/NearlyLuckyNumber/main_output0.txt b/NearlyLuckyNumber/main_output0.txt new file mode 100644 index 0000000..5e35d1b --- /dev/null +++ b/NearlyLuckyNumber/main_output0.txt @@ -0,0 +1 @@ +NO diff --git a/NearlyLuckyNumber/main_output1.txt b/NearlyLuckyNumber/main_output1.txt new file mode 100644 index 0000000..f033a50 --- /dev/null +++ b/NearlyLuckyNumber/main_output1.txt @@ -0,0 +1 @@ +YES diff --git a/NearlyLuckyNumber/main_output2.txt b/NearlyLuckyNumber/main_output2.txt new file mode 100644 index 0000000..5e35d1b --- /dev/null +++ b/NearlyLuckyNumber/main_output2.txt @@ -0,0 +1 @@ +NO |
