天天看點

Codeforces 490 C

​​傳送門​​

題目大意

思路

代碼

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");
}