Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- bool ch(string s)
- {
- int num=0;
- for(int i=0;i<s.size();++i){
- num*=10;
- num+=s[i]-'0';
- }
- return num%8==0;
- }
- int main()
- {
- string s,ss,ans="";
- cin>>s;
- for(int i=0;i<s.size();++i){
- if(s[i]=='0'){ans='0';break;}
- ss="";
- ss=s[i];
- if(ch(ss))ans=ss;
- for(int j=i+1;j<s.size();++j){
- ss=s[i];
- ss+=s[j];
- if(ch(ss))ans=ss;
- for(int k=j+1;k<s.size();++k){
- ss=s[i];
- ss+=s[j];
- ss+=s[k];
- if(ch(ss))ans=ss;
- }
- }
- }
- if(ans.size())cout<<"YES\n"<<ans<<endl;
- else cout<<"NO\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement