Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int a, b;
- cin>>a>>b;
- int c = 0;
- while (a>0 && b>0)
- {
- if (a > b)
- swap(a,b);
- a++, b-=2;
- c++;
- }
- cout<<c;
- return 0;
- }
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <math.h>
- using namespace std;
- int n;
- int val (string s)
- {
- int num=0, m=(n-2);
- for(int i=0; i<=m; i++)
- num += (s[i]-'0') * pow(10,m-i);
- return num;
- }
- int main()
- {
- string s, g;
- cin>>s;
- n = s.size();
- bool no=true;
- for(int i=0; i<n && no ; i++)
- {
- g.clear();
- for(int j=0; j<n; j++)
- if (j!=i)
- g+=s[j];
- if ( val(g)%8==0 )
- {
- cout<<"YES"<<endl<<g;
- no = false;
- }
- }
- if (no)
- cout<<"NO";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment