$edge = sqrt 2 * 10 ** 9;
@_ = (1) x $edge;
for $i (2..$edge){
$j = $i ** 2 + $i; # not excludes (prime ^ 2)s
while ($j < $edge){
$_[$j] = 0;
$j += $i;
}
}
@primes = ();
$_[$_-1] and push @primes, $_-1 for 1..@_; # made array of ~primes (2, 3, [4], 5, 7, [9], 11, 13, 17..)
@ans = ();
for (1..<>){
$false = 1;
for $i (@primes){
$g = $i; # copy of $i (~prime)
$i > $_ and last;
($_ + ($i % 2 ? 0 : $i / 2 )) % $i or ($false-- and last);
}
if ($_ / $g - $g / 2 + 1 < 1){ $false = 1}
push @ans,( $false ? IMPOSSIBLE
: ($_, " = ", join ' + ', ($_ / $g - $g / 2 + 1 .. $_ / $g + $g / 2))); }
JGVkZ2UgPSBzcXJ0IDIgKiAxMCAqKiA5OwoKQF8gPSAoMSkgeCAkZWRnZTsKCmZvciAkaSAoMi4uJGVkZ2UpewoJJGogPSAkaSAqKiAyICsgJGk7IAkjIG5vdCBleGNsdWRlcyAocHJpbWUgXiAyKXMKCXdoaWxlICgkaiA8ICRlZGdlKXsKCQkkX1skal0gPSAwOwoJCSRqICs9ICRpOwoJCX0KCX0KCQpAcHJpbWVzID0gKCk7CiRfWyRfLTFdIGFuZCBwdXNoIEBwcmltZXMsICRfLTEgZm9yIDEuLkBfOyAgCnNoaWZ0IEBwcmltZXM7IHNoaWZ0IEBwcmltZXM7CiMgbWFkZSBhcnJheSBvZiB+cHJpbWVzICgyLCAzLCBbNF0sIDUsIDcsIFs5XSwgMTEsIDEzLCAxNy4uKQoKQGFucyA9ICgpOwpmb3IgKDEuLjw+KXsKCSRfID0gPD4sIGNob21wOwoJJGZhbHNlID0gMTsKCWZvciAkaSAoQHByaW1lcyl7CgkJJGcgPSAkaTsgICMgY29weSBvZiAkaSAofnByaW1lKQoJCSRpID4gJF8gYW5kIGxhc3Q7IAoJCSgkXyArICgkaSAlIDIgPyAwIDogJGkgLyAyICkpICUgJGkgb3IgKCRmYWxzZS0tIGFuZCBsYXN0KTsKCQl9CglpZiAoJF8gLyAkZyAtICRnIC8gMiArIDEgPCAxKXsgJGZhbHNlID0gMX0KCXB1c2ggQGFucywoICRmYWxzZSA/IElNUE9TU0lCTEUgOiAoJF8sICIgPSAiLCBqb2luICcgKyAnLCAoJF8gLyAkZyAtICRnIC8gMiArIDEgLi4gJF8gLyAkZyArICRnIC8gMikpKTsKCXB1c2ggQGFucywgIlxuIjsKCX0KcHJpbnQgQGFucw==
MzAgLSBudW1iZXIgb2YgbGluZXMgd2lsbCB0cnkgdG8gc29sdmU6CjgKMTAKMjQKMQoyCjMKNAo1CjEyMwoxMjM0CjEyMzQ1CjEyMzQ1NgoxMjM0NTY3CjEyMzQ1Njc4CjEyMzQ1Njc4OQoxMDAwMDAwMDAwCjk5ODgxMjgwNwoxNDMKMjg2CjU3MgoxMTQ0CjIyODgKNDU3Ngo0NAo1NQo3Mg==
30 - number of lines will try to solve:
8
10
24
1
2
3
4
5
123
1234
12345
123456
1234567
12345678
123456789
1000000000
998812807
143
286
572
1144
2288
4576
44
55
72