-
Notifications
You must be signed in to change notification settings - Fork 0
/
C.cpp
74 lines (72 loc) · 1.48 KB
/
C.cpp
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
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0)
int main()
{
fastio;
string s;
int n,i,j,p=0,d;
cin>>s;
n=s.size();
for(i=0;i<1000;i+=8)
{
p=0;
if(i<10)
{
for(j=0;j<n;j++)
{
if(s[j]=='0'+i)
{
p=1;
break;
}
}
if(p)
{
cout<<"YES\n"<<i<<"\n";
break;
}
}
else if(i<100)
{
for(j=0;j<n;j++)
{
if(p==0 && s[j]=='0'+(i/10))
p=1;
else if(p==1 && s[j]=='0'+(i%10))
{
p=2;
break;
}
}
if(p==2)
{
cout<<"YES\n"<<i<<"\n";
break;
}
}
else
{
for(j=0;j<n;j++)
{
if(p==0 && s[j]=='0'+(i/100))
p=1;
else if(p==1 && s[j]=='0'+(i/10)%10)
p=2;
else if(p==2 && s[j]=='0'+(i%10))
{
p=3;
break;
}
}
if(p==3)
{
cout<<"YES\n"<<i<<"\n";
break;
}
}
p=0;
}
if(p==0)
cout<<"NO\n";
}