Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- int main() {
- int n,x;
- scanf("%d %d",&n,&x);
- int cuvajx=x;
- int j1,j2;
- int d1,d2;
- int i;
- int z1=0,z2=0;
- int j,z;
- int max=0;
- int cifrix=0,cifrin=0;
- int cuvajn;
- int cifran,cifrax;
- while(cuvajx>0) {
- cifrix++;
- cuvajx/=10;
- }
- for(i=n-1; i>=0; i--) {
- cuvajn=i;
- cifrin=0;
- z1=0;
- z2=0;
- cuvajn=i;
- d1=1;
- d2=1;
- while(cuvajn>0) {
- cifrin++;
- cuvajn/=10;
- }
- for(j1=1; j1<=cifrin; j1++) {
- cifran=i/d1%10;
- d2=1;
- z2=0;
- for(j2=1; j2<=cifrix; j2++) {
- cifrax=x/d2%10;
- if(cifran!=cifrax)
- z2++;
- d2*=10;
- }
- if(z2==cifrix)
- z1++;
- d1*=10;
- }
- if(z1==cifrin)
- {
- max=i;
- break;
- }
- }
- printf("%d",max);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement