-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path146A.cpp
More file actions
31 lines (28 loc) · 725 Bytes
/
146A.cpp
File metadata and controls
31 lines (28 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fo(i,n) for(int i = 0; i < n; i++)
#define endl '\n'
bool lucky_num(string x){
for(int i = 0;i<x.size();i++){
if (x[i] != '7' && x[i] !='4') return false;
}
return true;
}
int main() {
int n;
cin >> n;
string ticket;
cin >> ticket;
int primeira_parte = 0;
int segunda_parte = 0;
for(int i = 0;i<n;i++){
if(i<n/2) primeira_parte+=ticket[i]-'0';
else segunda_parte += ticket[i]-'0';
}
bool tag = lucky_num(ticket) ;
tag == true && primeira_parte == segunda_parte ? cout << "YES" : cout << "NO";
return 0;
}