One ABCD and EFGH represent four digits, in which each letter (A - H) represents 1-9 of which A number, the different letters represent Numbers, please type on calculate how many kind of solution? For example: 4613-2597=2016 is one of the solutions,
CodePudding user response:
# include & lt; stdio.h># define the check (x) if (flag [x]) continue; The else flag [x] + +
Int main () {
For (int I=3017; I<9999; I++) {
Int flag [10]={0};
Int a, b, c, d;
Int t=I;
D=t % 10; t/=10; Check (d);
C=t % 10; t/=10; Check (c);
B=t % 10; t/=10; Check (b);
A=t; Check (a);
T=I - 2016;
Int e, f, g, h;
H=t % 10; t/=10; Check (h);
G=t % 10; t/=10; Check (g);
F=t % 10; t/=10; Check (f);
E=t; Check (e);
Printf (" % d, % d=2016 \ n ", I, I - 2016);
}
return 0;
}
3502-1486=2016
3508-1492=2016
3608-1592=2016
3705-1689=2016
3708-1692=2016
4603-2587=2016
4607-2591=2016
4613-2597=2016
4701-2685=2016
4705-2689=2016
5708-3692=2016
5710-3694=2016
5714-3698=2016
5810-3794=2016
5812-3796=2016
6203-4187=2016
6205-4189=2016
6301-4285=2016
6305-4289=2016
6307-4291=2016
7310-5294=2016
7314-5298=2016
7402-5386=2016
7408-5392=2016
7412-5396=2016
8307-6291=2016
8310-6294=2016
8407-6391=2016
8507-6491=2016
8513-6497=2016
9301-7285=2016
9401-7385=2016
9402-7386=2016
9502-7486=2016
CodePudding user response:
# include & lt; stdio.h>Int main () {
Int nCount=0;
For (int I=3017; I<9999; I++) {
Int flag [10]={0};
Int t=I * 10000 + l (I - 2016);
Int j=0, v=0;
For (; j<8; J++) {
V=t % 10;
If (flag [v]) break; The else flag [v] + +;
T/=10;
}
If (j!=8) continue;
NCount + +;
Printf (" % d, % d=2016 \ n ", I, I - 2016);
}
Printf (" \ n \ nTotal: % d ", nCount);
return 0;
}
CodePudding user response:
Fun