Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <cstdlib>
- #include <string>
- #include <sstream>
- #define F(i,a,b) for (int i=a; i<=b; i++)
- #define Ss stringstream
- #define L length()
- using namespace std;
- string st;
- int go(int z)
- {
- int tp=0;
- while (z)
- {
- tp+=(z%10); z/=10;
- }
- if (tp>9) go(tp); else return tp;
- }
- bool c(int k)
- {
- int x=0,y=0;
- string s1,s2;
- F(i,0,k-1) s1+=st[i];
- F(i,k,st.L-1) s2+=st[i];
- Ss(s1)>>x; Ss(s2)>>y;
- x=go(x); y=go(y);
- cout<<x<<" "<<y<<endl;
- if (x==y) return 1; else
- return 0;
- }
- int main()
- {
- freopen("input.txt","rt",stdin);
- freopen("output.txt","wt",stdout);
- cin>>st;
- F(i,1,st.L-1)
- if (c(i)) cout<<"YES",exit(0);
- cout<<"NO";
- }
Advertisement
Add Comment
Please, Sign In to add comment