Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- string a;
- long long b,c,i,j,n,x,y,z,rem=0,p,q,r;
- cin>>a;
- x=a.size();
- cin>>b>>c;
- for(i=0;i<x;i++)
- {
- y=a[i]-48;
- rem=rem*10+y;
- rem=rem%b;
- if(rem==0)
- {
- z=i;
- p=1;
- if((z+1)==x-1 && a[z+1]=='0')
- {
- break;
- }
- }
- }
- rem=0;
- if((z+1)==x-1 && a[z+1]=='0')
- {
- cout<<"NO";
- return 0;
- }
- for(i=z+1;i<x;i++)
- {
- q=a[i]-48;
- rem=rem*10+q;
- rem=rem%c;
- }
- if(rem==0 && p==1)
- {
- cout<<"YES"<<endl;
- for(i=0;i<=z;i++)
- {
- cout<<a.at(i);
- }
- cout<<endl;
- for(i=z+1;i<x;i++)
- {
- cout<<a.at(i);
- }
- }
- else
- {
- cout<<"NO"<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement