​传送门​

题目大意

Codeforces 490 C_整除分成两个部分,其中,左边被Codeforces 490 C_预处理_02整除,右边被Codeforces 490 C_预处理_03整除,且不能有前导0
Codeforces 490 C_整除_04,Codeforces 490 C_预处理_05

思路

预处理前缀模和后缀模就好

代码

char s[maxn];
ll a,b;
ll c[maxn],d[maxn];

int main(){
scanf("%s",s+1);
scanf("%lld%lld",&a,&b);
int len=strlen(s+1);
for(int i=1;i<=len;i++){
c[i]=(c[i-1]*10+s[i]-'0')%a;
}
ll tmp=1;
for(int i=len;i>=1;i--){
d[i]=(tmp*(s[i]-'0')+d[i+1])%b;
tmp=tmp*10%b;
}
for(int i=1;i<len;i++){
if(c[i]==0&&s[i+1]!='0'&&d[i+1]==0){
puts("YES");
for(int j=1;j<=i;j++){
printf("%c",s[j]);
}
puts("");
for(int j=i+1;j<=len;j++){
printf("%c",s[j]);
}
return 0;
}
}
puts("NO");
}