for(a=1; a<10; a++)
for(b=1; b<10; b++)
for(c=1; c<10; c++)
for(d=1; d<10; d++)
for(e=1; e<10; e++)
for(f=1; f<10; f++)
for(g=1; g<10; g++)
for(h=1; h<10; h++)
for(j=1; j<10; j++)
if( 100*d+10*g+j + 100*j+10*a+e + 100*b+10*h+f == 1000*d+100*d+10*a+b &&
f*c/j == 10*g+a &&
a!=b && a!=c && a!=d && a!=e && a!=f && a!=g && a!=h && a!=j &&
b!=c && b!=d && b!=e && b!=f && b!=g && b!=h && b!=j &&
c!=d && c!=e && c!=f && c!=g && c!=h && c!=j &&
d!=e && d!=f && d!=g && d!=h && d!=j &&
e!=f && e!=g && e!=h && e!=j &&
f!=g && f!=h && f!=j &&
g!=h && g!=j &&
h!=j )
alert( " a="+a+
" b="+b+
" c="+c+
" d="+d+
" e="+e+
" f="+f+
" g="+g+
" h="+h+
" j="+j);
<?php
for($a=1; $a<10; $a++)
for($b=1; $b<10; $b++)
for($c=1; $c<10; $c++)
for($d=1; $d<10; $d++)
for($e=1; $e<10; $e++)
for($f=1; $f<10; $f++)
for($g=1; $g<10; $g++)
for($h=1; $h<10; $h++)
for($j=1; $j<10; $j++)
if( 100*$d+10*$g+$j + 100*$j+10*$a+$e + 100*$b+10*$h+$f == 1000*$d+100*$d+10*$a+$b &&
$f*$c/$j == 10*$g+$a &&
$a!=$b && $a!=$c && $a!=$d && $a!=$e && $a!=$f && $a!=$g && $a!=$h && $a!=$j &&
$b!=$c && $b!=$d && $b!=$e && $b!=$f && $b!=$g && $b!=$h && $b!=$j &&
$c!=$d && $c!=$e && $c!=$f && $c!=$g && $c!=$h && $c!=$j &&
$d!=$e && $d!=$f && $d!=$g && $d!=$h && $d!=$j &&
$e!=$f && $e!=$g && $e!=$h && $e!=$j &&
$f!=$g && $f!=$h && $f!=$j &&
$g!=$h && $g!=$j &&
$h!=$j )
echo " a=",$a,
" b=",$b,
" c=",$c,
" d=",$d,
" e=",$e,
" f=",$f,
" g=",$g,
" h=",$h,
" j=",$j;
?>
if( 100*$d+10*$g+$j + 100*$j+10*$a+$e + 100*$b+10*$h+$f == 1000*$d+100*$d+10*$a+$b && $f*$c/$j == 10*$g+$a) {
echo " a=",$a, " b=",$b, " c=",$c, " d=",$d, " e=",$e, " f=",$f, " g=",$g, " h=",$h, " j=",$j;
break 9;
}
package main
import "fmt"
import "time"
func main() {
st := time.Now().UnixNano()
top:
for a := 1; a<10; a++ {
for b := 1; b<10; b++ {
if b == a { continue; } else {
for c := 1; c<10; c++ {
if c==b || c==a { continue; } else {
for d := 1; d<10; d++ {
if d==c || d==b || d==a { continue; } else {
for e := 1; e<10; e++ {
if e==d || e==c || e==b || e==a { continue; } else {
for f := 1; f<10; f++ {
if f==e || f==d || f==c || f==b || f==a { continue; } else {
for g := 1; g<10; g++ {
if g==f || g==e || g==d || g==c || g==b || g==a { continue; } else {
for h := 1; h<10; h++ {
if h==g || h==f || h==e || h==d || h==c || h==b || h==a { continue; } else {
for j := 1; j<10; j++ {
if j==h || j==g || j==f || j==e || j==d || j==c || j==b || j==a { continue; } else {
if 100*d+10*g+j + 100*j+10*a+e + 100*b+10*h+f == 1000*d+100*d+10*a+b && f*c/j == 10*g+a {
fmt.Println(" a=", a, " b=", b, " c=", c, " d=", d, " e=", e, " f=", f, " g=", g, " h=", h, " j=", j)
break top
}}}}}}}}}}}}}}}}}}
elapsed := time.Now().UnixNano()
delta := ( float64(elapsed) - float64(st) )/ 1e6
fmt.Println("Время выполнения (ms): ", delta)
}
var time = performance.now();
// некий код
time = performance.now() - time;
console.log('Время выполнения (ms): ', time);
<?php
for($a=9; $a>=1; $a--) {
$a10 = 10*$a;
for($b=9; $b>=1; $b--) {
if ($a===$b) continue;
$b100 = 100*$b;
for($c=9; $c>=1; $c--) {
if ($a===$c || $b===$c) continue;
for($d=9; $d>=1; $d--) {
if ($a===$d || $b===$d || $c===$d) continue;
$d100 = 100*$d;
$v2 = 1000*$d+$d100+$a10+$b;
for($e=9; $e>=1; $e--) {
if ($a===$e || $b===$e || $c===$e || $d===$e) continue;
for($f=9; $f>=1; $f--) {
if (
$a===$f || $b===$f || $c===$f ||
$d===$f || $e===$f
) continue;
$fc=$f*$c;
for($g=9; $g>=1; $g--) {
if (
$a===$g || $b===$g || $c===$g ||
$d===$g || $e===$g || $f===$g
) continue;
$g10 = 10 * $g;
$g10a = $g10+$a;
for($h=9; $h>=1; $h--) {
if (
$a===$h || $b===$h || $c===$h ||
$d===$h || $e===$h || $f===$h || $g===$h
) continue;
$v3 = $b100+10*$h+$f;
for($j=9; $j>=1; $j--) {
if (
$a===$j || $b===$j || $c===$j || $d===$j ||
$e===$j || $f===$j || $g===$j || $h===$j
) continue;
if(
$d100+$g10+$j + 100*$j+$a10+$e + $v3 === $v2
&& $fc/$j === $g10a
) {
echo "\n a=",$a,
" b=",$b,
" c=",$c,
" d=",$d,
" e=",$e,
" f=",$f,
" g=",$g,
" h=",$h,
" j=",$j,"\n\n";
}
}
}
}
}
}
}
}
}
}
func gen() [][]int {
res := [][]int{}
for f := 0; f < 10; f++ {
for c := 0; c < 10; c++ {
if c == f { continue }
for j := 1; j < 10; j++ {
if j == f || j == c { continue }
x := int(f * c / j)
g := int(x / 10)
a := x % 10
if f != g && f != a && c != g && c != a && j != g && j != a && g != a && 100 > f * c/j && f * c/j > 9 && f * c%j == 0 {
res = append(res, []int{f, c, j, g, a})
}
}
}
}
return res
}
func calc() {
items := gen()
top:
for d := 0; d < 10; d++ {
for e := 0; e < 10; e++ {
if e == d { continue }
for b := 0; b < 10; b++ {
if d == b || e == b { continue }
for h := 0; h < 10; h++ {
if d == h || e == h || b == h { continue }
for _, item := range items {
if d*100+item[3]*10+item[2]+ item[2]*100+item[4]*10+e+ b*100+h*10+item[0]==d*1000+d*100+item[4]*10+b {
if item[0] != b && item[0] != d && item[0] != e && item[0] != h &&
item[1] != b && item[1] != d && item[1] != e && item[1] != h &&
item[2] != b && item[2] != d && item[2] != e && item[2] != h &&
item[3] != b && item[3] != d && item[3] != e && item[3] != h &&
item[4] != b && item[4] != d && item[4] != e && item[4] != h {
fmt.Println("a =", item[4], " b =", b, " c =", item[1], " d =", d, " e =", e, " f =", item[0], " g =", item[3], " h =", h, " j =", item[2])
break top
}
}
}
}
}
}
}
}
st := time.Now().UnixNano()
calc()
fmt.Println("Время выполнения (ms): ", (float64(time.Now().UnixNano()) - float64(st)) / 1e6)
# a = 4 b = 6 c = 9 d = 1 e = 5 f = 8 g = 2 h = 7 j = 3
# Время выполнения (ms): 0.498432