FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Competitive-Programming/AddEmUp.cpp at master · KevinMathewT/Competitive-Programming · GitHub
KevinMathewT
/
Competitive-Programming
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
3
Code
Issues
0
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Competitive-Programming
/
AddEmUp.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
116 lines (98 loc) · 2.41 KB
Breadcrumbs
Competitive-Programming
/
AddEmUp.cpp
Copy path
File metadata and controls
116 lines (98 loc) · 2.41 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#
include
<
bits/stdc++.h
>
using
namespace
std
;
typedef
long
long
ll;
typedef
double
ld;
#
define
F
first
#
define
S
second
template
<
class
T
> ostream&
operator
<<(ostream &os, vector<T> V) {
os <<
"
[
"
;
for
(
auto
v : V) os << v <<
"
"
;
os <<
"
]
"
;
return
os;
}
template
<
class
T
> ostream&
operator
<<(ostream &os, set<T> S){
os <<
"
{
"
;
for
(
auto
s:S) os<<s<<
"
"
;
return
os<<
"
}
"
;
}
template
<
class
L
,
class
R
> ostream&
operator
<<(ostream &os, pair<L,R> P) {
return
os <<
"
(
"
<< P.
first
<<
"
,
"
<< P.
second
<<
"
)
"
;
}
template
<
class
L
,
class
R
> ostream&
operator
<<(ostream &os, map<L,R> M) {
os <<
"
{
"
;
for
(
auto
m:M) os<<
"
(
"
<<m.
F
<<
"
:
"
<<m.
S
<<
"
)
"
;
return
os<<
"
}
"
;
}
//
Kevin Mathew T
//
Birla Institute of Technology, Mesra
//
GitHub - https://github.com/KevinMathewT
//
CodeForces - https://codeforces.com/profile/KevinMathew
//
CodeChef - https://www.codechef.com/users/KevinMathew
//
HackerRank - https://www.hackerrank.com/KevinMathew?
ll n, sum, a[
100010
];
unordered_map<ll, ll> m;
void
solve
(){
cin >> n >> sum;
for
(ll i=
0
;i<n;i++)
cin >> a[i];
for
(ll i=
0
;i<n;i++){
string s =
to_string
(a[i]);
vector<ll>
p
(
1
,
0
);
//
cout << s << "\n";
for
(ll i=
0
;i<s.
size
();i++){
if
(s[i] !=
'
2
'
&& s[i] !=
'
5
'
&& s[i] !=
'
6
'
&& s[i] !=
'
9
'
){
for
(ll j=
0
;j<p.
size
();j++)
p[j] = p[j] *
10
+ (s[i] -
'
0
'
);
}
else
{
ll sz = p.
size
();
for
(ll j=
0
;j<sz;j++)
p.
push_back
(p[j]);
if
(s[i] ==
'
2
'
){
for
(ll j=
0
;j<sz;j++)
p[j] = p[j] *
10
+
2
;
for
(ll j=sz;j<
2
*sz;j++)
p[j] = p[j] *
10
+
5
;
}
if
(s[i] ==
'
5
'
){
for
(ll j=
0
;j<sz;j++)
p[j] = p[j] *
10
+
2
;
for
(ll j=sz;j<
2
*sz;j++)
p[j] = p[j] *
10
+
5
;
}
//
cout << p << "\n";
if
(s[i] ==
'
6
'
){
for
(ll j=
0
;j<sz;j++)
p[j] = p[j] *
10
+
6
;
for
(ll j=sz;j<
2
*sz;j++)
p[j] = p[j] *
10
+
9
;
}
if
(s[i] ==
'
9
'
){
for
(ll j=
0
;j<sz;j++)
p[j] = p[j] *
10
+
6
;
for
(ll j=sz;j<
2
*sz;j++)
p[j] = p[j] *
10
+
9
;
}
}
}
//
cout << p << "\n";
for
(ll j=
0
;j<p.
size
();j++)
if
(m.
find
(sum - p[j]) != m.
end
()){
cout <<
"
YES
\n
"
;
return
;
}
for
(ll j=
0
;j<p.
size
();j++)
m[p[j]] =
1
;
}
cout <<
"
NO
\n
"
;
}
int
main
()
{
//
freopen("input.txt", "r", stdin); //Comment
//
freopen("output.txt", "w", stdout); //this out.
ios::sync_with_stdio
(
false
);
//
Not
cin.
tie
(
NULL
);
//
this.
cout.
tie
(
0
);
//
or this.
solve
();
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL