Created
November 16, 2017 02:28
-
-
Save byron-perez/9903cf614f94b1549087e32f20dd86a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int numDigits(int number) | |
{ | |
int digits = 0; | |
if (number < 0) digits = 1; // remove this line if '-' counts as a digit | |
while (number) { | |
number /= 10; | |
digits++; | |
} | |
return digits; | |
} | |
int main() { | |
int n; | |
vector<int> passed; | |
cin >> n; | |
for(int a0 = 0; a0 < n; a0++){ | |
string name; | |
int value; | |
cin >> name >> value; | |
vector<int> digits; | |
while (value) | |
{ | |
digits.push_back(value%10); | |
value /= 10; | |
} | |
int sz = digits.size(); | |
if (sz%2 != 0) | |
cout << -1 << endl; | |
else | |
{ | |
int fours = 0; | |
int sevens = 0; | |
for (int i = 0; i < sz; i++) | |
{ | |
if ((digits[i] != 4) || (digits[i] != 7)) | |
{ | |
cout << -1 << endl; | |
break; | |
} | |
if (digits[i] == 4) | |
fours++; | |
if (digits[i] == 7) | |
sevens++; | |
} | |
if (fours == sevens) | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment