题意:
思路:
已放弃
1 #include <bits/stdc++.h> 2 typedef long long LL; 3 4 int main(){ 5 int T; scanf("%d", &T); 6 while(T--){ 7 int a; char s[10]; 8 scanf("%d%s", &a, s); 9 LL b; 10 for(b = a;; b += a){ 11 char t[20]; 12 sprintf(t, "%lld", b); 13 if(!strcmp(s, t)) goto finish; 14 int tl = strlen(t), sl = strlen(s); 15 int rn = tl - sl; 16 if(rn < 0) continue; 17 for(int i = 0; i <= sl; ++i) 18 for(int j = 1, til; (til = i + (rn - 1) * j) < tl && j < tl; ++j){ 19 for(int k = 0, l = 0; k < sl; ++k, ++l){ 20 while(l >= i && l <= til && !((l - i) % j)) ++l; 21 if(s[k] != t[l]) goto fail; 22 } 23 goto finish; 24 fail:; 25 } 26 } 27 finish: 28 printf("%lld ", b); 29 } 30 // printf("clock %d ", (int) clock()); 31 return 0; 32 }