/
042.php
67 lines (67 loc) · 1.31 KB
/
042.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
$answer = 0;
ini_set('max_execution_time', 3000);
function p($a){return gmp_strval(gmp_fact($a));}
$n="0123456789";
$len= p(strlen($n));
for($i=1;$i<=$len;$i++){
$str = [];
$l=strlen($n);
$m = $i;
$a=str_split($n);
$m--;
do{
$f=floor($m/p($l-1));
array_push($str,$a[$f]);
array_splice($a, $f, 1);
$a=array_values($a);
$m-=($f*p($l-1));
$l--;
}while($m!=0);
foreach($a as$m=>$e)
array_push($str,$e);
$new = $str;
$new = implode(array_splice($new,-3,3));
if($new % 17 != 0)
continue;
else{
$new = $str;
$new = implode(array_splice($new,-4,3));
if($new % 13 !=0)
continue;
else{
$new = $str;
$new = implode(array_splice($new,-5,3));
if($new % 11 !=0)
continue;
else{
$new = $str;
$new = implode(array_splice($new,-6,3));
if($new % 7 !=0)
continue;
else{
$new = $str;
$new = implode(array_splice($new,-7,3));
if($new % 5 !=0)
continue;
else{
$new = $str;
$new = implode(array_splice($new,-8,3));
if($new % 3 !=0)
continue;
else{
$new = $str;
$new = implode(array_splice($new,-9,3));
if($new % 2 !=0)
continue;
else
$answer += implode($str);
}
}
}
}
}
}
}
echo $answer;
?>