А решения для N=8,9,10 есть у кого-нибудь?
Оптимальных решений может быть много. Вот все которые я нашёл для N=1-12:
(Оффтоп)
N=1
0: 1
N=2
1: 1, 2
N=3
3: 1, 2, 3, 6
3: 1, 2, 4, 6
N=4
4: 1, 2, 4, 6, 24
N=5
6: 1, 2, 4, 16, 14, 30, 120
6: 1, 2, 4, 16, 32, 30, 120
6: 1, 2, 4, 16, 64, 60, 120
6: 1, 2, 4, 8, 7, 15, 120
6: 1, 2, 4, 8, 32, 30, 120
6: 1, 2, 4, 8, 64, 60, 120
6: 1, 2, 3, 6, 18, 20, 120
6: 1, 2, 4, 6, 24, 30, 120
6: 1, 2, 4, 6, 24, 20, 120
6: 1, 2, 4, 6, 36, 30, 120
6: 1, 2, 3, 6, 12, 10, 120
6: 1, 2, 3, 4, 12, 10, 120
6: 1, 2, 4, 16, 12, 10, 120
6: 1, 2, 4, 5, 25, 30, 120
6: 1, 2, 4, 5, 25, 24, 120
6: 1, 2, 4, 5, 10, 12, 120
6: 1, 2, 4, 5, 20, 24, 120
6: 1, 2, 4, 16, 20, 6, 120
6: 1, 2, 4, 8, 10, 12, 120
6: 1, 2, 3, 5, 25, 24, 120
6: 1, 2, 3, 5, 10, 12, 120
6: 1, 2, 3, 9, 10, 12, 120
6: 1, 2, 3, 5, 8, 40, 120
6: 1, 2, 3, 5, 8, 24, 120
6: 1, 2, 3, 5, 8, 15, 120
6: 1, 2, 4, 5, 6, 30, 120
6: 1, 2, 4, 5, 6, 24, 120
6: 1, 2, 4, 5, 6, 20, 120
6: 1, 2, 4, 6, 10, 60, 120
6: 1, 2, 4, 6, 10, 20, 120
6: 1, 2, 4, 6, 10, 12, 120
6: 1, 2, 4, 16, 15, 60, 120
6: 1, 2, 4, 16, 15, 30, 120
6: 1, 2, 4, 16, 15, 8, 120
6: 1, 2, 3, 5, 25, 125, 120
6: 1, 2, 4, 5, 20, 100, 120
6: 1, 2, 4, 5, 25, 125, 120
6: 1, 2, 4, 6, 24, 96, 120
6: 1, 2, 3, 9, 12, 108, 120
6: 1, 2, 3, 9, 11, 121, 120
6: 1, 2, 4, 16, 8, 128, 120
6: 1, 2, 4, 8, 32, 128, 120
6: 1, 2, 4, 8, 64, 56, 120
6: 1, 2, 4, 8, 64, 128, 120
N=6
6: 1, 2, 4, 16, 20, 36, 720
6: 1, 2, 3, 9, 81, 80, 720
6: 1, 2, 4, 6, 24, 30, 720
6: 1, 2, 3, 9, 27, 729, 720
6: 1, 2, 3, 9, 81, 729, 720
N=7
7: 1, 2, 3, 6, 12, 72, 70, 5040
7: 1, 2, 4, 6, 36, 72, 70, 5040
7: 1, 2, 4, 6, 36, 144, 140, 5040
7: 1, 2, 4, 6, 36, 1296, 1260, 5040
7: 1, 2, 4, 6, 12, 72, 70, 5040
7: 1, 2, 4, 8, 9, 72, 70, 5040
7: 1, 2, 4, 16, 18, 72, 70, 5040
7: 1, 2, 3, 9, 8, 72, 70, 5040
7: 1, 2, 3, 6, 36, 72, 70, 5040
7: 1, 2, 3, 9, 81, 72, 70, 5040
7: 1, 2, 4, 8, 64, 72, 70, 5040
7: 1, 2, 4, 16, 256, 252, 20, 5040
7: 1, 2, 4, 16, 64, 63, 80, 5040
7: 1, 2, 4, 6, 36, 35, 1260, 5040
7: 1, 2, 4, 6, 36, 35, 140, 5040
7: 1, 2, 4, 6, 36, 35, 144, 5040
N=8
8: 1, 2, 4, 8, 64, 4096, 4032, 10, 40320
8: 1, 2, 4, 16, 14, 196, 210, 192, 40320
8: 1, 2, 4, 6, 36, 1296, 1260, 32, 40320
8: 1, 2, 4, 6, 36, 35, 32, 1120, 40320
8: 1, 2, 4, 6, 36, 35, 32, 1152, 40320
8: 1, 2, 4, 6, 36, 35, 32, 1260, 40320
8: 1, 2, 3, 6, 36, 35, 32, 1120, 40320
8: 1, 2, 3, 6, 36, 35, 32, 1152, 40320
8: 1, 2, 3, 6, 36, 35, 32, 1260, 40320
8: 1, 2, 4, 16, 20, 36, 56, 2016, 40320
8: 1, 2, 4, 16, 20, 36, 56, 1120, 40320
8: 1, 2, 4, 16, 20, 36, 56, 720, 40320
8: 1, 2, 4, 16, 32, 36, 35, 1260, 40320
8: 1, 2, 4, 16, 32, 36, 35, 1120, 40320
8: 1, 2, 4, 16, 32, 36, 35, 1152, 40320
8: 1, 2, 4, 8, 32, 36, 35, 1260, 40320
8: 1, 2, 4, 8, 32, 36, 35, 1120, 40320
8: 1, 2, 4, 8, 32, 36, 35, 1152, 40320
8: 1, 2, 4, 8, 64, 63, 10, 630, 40320
8: 1, 2, 4, 8, 64, 63, 10, 640, 40320
8: 1, 2, 4, 8, 64, 63, 10, 4032, 40320
8: 1, 2, 4, 16, 14, 196, 180, 2520, 40320
8: 1, 2, 4, 16, 14, 196, 180, 2880, 40320
8: 1, 2, 4, 16, 14, 196, 180, 224, 40320
8: 1, 2, 4, 8, 64, 72, 70, 5040, 40320
8: 1, 2, 4, 8, 64, 72, 70, 560, 40320
8: 1, 2, 4, 8, 64, 72, 70, 576, 40320
8: 1, 2, 3, 9, 8, 72, 70, 5040, 40320
8: 1, 2, 3, 9, 8, 72, 70, 560, 40320
8: 1, 2, 3, 9, 8, 72, 70, 576, 40320
8: 1, 2, 4, 8, 9, 72, 70, 5040, 40320
8: 1, 2, 4, 8, 9, 72, 70, 560, 40320
8: 1, 2, 4, 8, 9, 72, 70, 576, 40320
8: 1, 2, 4, 8, 12, 144, 140, 20160, 40320
8: 1, 2, 4, 8, 12, 144, 140, 280, 40320
8: 1, 2, 4, 8, 12, 144, 140, 288, 40320
8: 1, 2, 4, 6, 12, 144, 140, 20160, 40320
8: 1, 2, 4, 6, 12, 144, 140, 280, 40320
8: 1, 2, 4, 6, 12, 144, 140, 288, 40320
8: 1, 2, 4, 6, 36, 144, 140, 20160, 40320
8: 1, 2, 4, 6, 36, 144, 140, 280, 40320
8: 1, 2, 4, 6, 36, 144, 140, 288, 40320
8: 1, 2, 3, 4, 12, 144, 140, 20160, 40320
8: 1, 2, 3, 4, 12, 144, 140, 280, 40320
8: 1, 2, 3, 4, 12, 144, 140, 288, 40320
8: 1, 2, 4, 16, 12, 144, 140, 20160, 40320
8: 1, 2, 4, 16, 12, 144, 140, 280, 40320
8: 1, 2, 4, 16, 12, 144, 140, 288, 40320
8: 1, 2, 4, 6, 24, 144, 140, 20160, 40320
8: 1, 2, 4, 6, 24, 144, 140, 280, 40320
8: 1, 2, 4, 6, 24, 144, 140, 288, 40320
N=9
8: 1, 2, 4, 8, 64, 72, 70, 5040, 362880
8: 1, 2, 4, 8, 64, 72, 70, 5184, 362880
8: 1, 2, 3, 9, 8, 72, 70, 5040, 362880
8: 1, 2, 3, 9, 8, 72, 70, 5184, 362880
8: 1, 2, 4, 8, 9, 72, 70, 5040, 362880
8: 1, 2, 4, 8, 9, 72, 70, 5184, 362880
8: 1, 2, 3, 6, 36, 72, 70, 5040, 362880
8: 1, 2, 3, 6, 36, 72, 70, 5184, 362880
8: 1, 2, 4, 6, 12, 72, 70, 5040, 362880
8: 1, 2, 4, 6, 12, 72, 70, 5184, 362880
8: 1, 2, 3, 6, 12, 72, 70, 5040, 362880
8: 1, 2, 3, 6, 12, 72, 70, 5184, 362880
8: 1, 2, 4, 16, 18, 72, 70, 5040, 362880
8: 1, 2, 4, 16, 18, 72, 70, 5184, 362880
8: 1, 2, 4, 6, 36, 72, 70, 5040, 362880
8: 1, 2, 4, 6, 36, 72, 70, 5184, 362880
8: 1, 2, 3, 9, 81, 72, 70, 5040, 362880
8: 1, 2, 3, 9, 81, 72, 70, 5184, 362880
N=10
9: 1, 2, 4, 16, 64, 60, 63, 240, 57600, 3628800
9: 1, 2, 4, 16, 64, 60, 63, 240, 15120, 3628800
9: 1, 2, 4, 8, 64, 60, 63, 240, 57600, 3628800
9: 1, 2, 4, 8, 64, 60, 63, 240, 15120, 3628800
9: 1, 2, 4, 16, 15, 64, 63, 240, 57600, 3628800
9: 1, 2, 4, 16, 15, 64, 63, 240, 15120, 3628800
9: 1, 2, 4, 6, 36, 144, 140, 180, 25200, 3628800
9: 1, 2, 4, 6, 36, 144, 140, 180, 25920, 3628800
9: 1, 2, 4, 6, 36, 144, 140, 180, 20160, 3628800
9: 1, 2, 4, 6, 24, 144, 150, 168, 25200, 3628800
9: 1, 2, 4, 6, 24, 144, 150, 168, 24192, 3628800
9: 1, 2, 4, 6, 24, 144, 150, 168, 21600, 3628800
9: 1, 2, 4, 16, 256, 240, 64, 63, 15120, 3628800
9: 1, 2, 4, 16, 256, 240, 64, 63, 57600, 3628800
9: 1, 2, 4, 16, 64, 60, 63, 960, 60480, 3628800
9: 1, 2, 4, 16, 64, 60, 63, 960, 57600, 3628800
9: 1, 2, 4, 16, 64, 60, 63, 1008, 60480, 3628800
9: 1, 2, 3, 9, 81, 80, 7, 567, 45360, 3628800
9: 1, 2, 3, 9, 81, 80, 7, 560, 44800, 3628800
9: 1, 2, 3, 9, 81, 80, 7, 560, 45360, 3628800
9: 1, 2, 4, 16, 64, 60, 1024, 1008, 60480, 3628800
9: 1, 2, 4, 16, 64, 60, 1024, 1008, 3600, 3628800
9: 1, 2, 4, 16, 12, 28, 30, 360, 129600, 3628800
9: 1, 2, 4, 16, 12, 28, 30, 360, 10080, 3628800
9: 1, 2, 4, 16, 64, 60, 63, 3600, 226800, 3628800
9: 1, 2, 4, 16, 64, 60, 63, 3600, 57600, 3628800
9: 1, 2, 4, 16, 64, 60, 63, 3600, 1008, 3628800
9: 1, 2, 4, 16, 64, 60, 63, 3780, 226800, 3628800
9: 1, 2, 4, 16, 64, 60, 63, 3780, 60480, 3628800
9: 1, 2, 4, 16, 64, 60, 63, 3780, 960, 3628800
9: 1, 2, 3, 9, 81, 80, 7, 720, 518400, 3628800
9: 1, 2, 3, 9, 81, 80, 7, 720, 5040, 3628800
9: 1, 2, 3, 9, 81, 80, 7, 6480, 45360, 3628800
9: 1, 2, 3, 9, 81, 80, 7, 6480, 518400, 3628800
9: 1, 2, 3, 9, 81, 80, 7, 6480, 560, 3628800
9: 1, 2, 3, 9, 81, 80, 7, 6400, 44800, 3628800
9: 1, 2, 3, 9, 81, 80, 7, 6400, 518400, 3628800
9: 1, 2, 3, 9, 81, 80, 7, 6400, 567, 3628800
9: 1, 2, 3, 5, 7, 12, 144, 720, 518400, 3628800
9: 1, 2, 3, 5, 7, 12, 144, 720, 5040, 3628800
9: 1, 2, 4, 5, 7, 12, 144, 720, 518400, 3628800
9: 1, 2, 4, 5, 7, 12, 144, 720, 5040, 3628800
9: 1, 2, 3, 5, 7, 12, 60, 720, 518400, 3628800
9: 1, 2, 3, 5, 7, 12, 60, 720, 5040, 3628800
9: 1, 2, 4, 5, 7, 12, 60, 720, 518400, 3628800
9: 1, 2, 4, 5, 7, 12, 60, 720, 5040, 3628800
9: 1, 2, 4, 6, 24, 30, 7, 720, 518400, 3628800
9: 1, 2, 4, 6, 24, 30, 7, 720, 5040, 3628800
9: 1, 2, 3, 9, 27, 729, 720, 7, 5040, 3628800
9: 1, 2, 3, 9, 27, 729, 720, 7, 518400, 3628800
9: 1, 2, 3, 9, 81, 729, 720, 7, 5040, 3628800
9: 1, 2, 3, 9, 81, 729, 720, 7, 518400, 3628800
9: 1, 2, 4, 16, 64, 60, 3840, 3780, 226800, 3628800
9: 1, 2, 4, 16, 64, 60, 3840, 3780, 60480, 3628800
9: 1, 2, 4, 16, 64, 60, 3840, 3780, 960, 3628800
9: 1, 2, 4, 16, 15, 60, 960, 945, 907200, 3628800
9: 1, 2, 4, 16, 15, 60, 960, 945, 3780, 3628800
9: 1, 2, 4, 16, 15, 60, 960, 945, 3840, 3628800
9: 1, 2, 4, 16, 15, 240, 960, 945, 907200, 3628800
9: 1, 2, 4, 16, 15, 240, 960, 945, 226800, 3628800
9: 1, 2, 4, 16, 15, 240, 960, 945, 15120, 3628800
9: 1, 2, 4, 16, 15, 240, 960, 945, 3780, 3628800
9: 1, 2, 4, 16, 15, 240, 960, 945, 3840, 3628800
9: 1, 2, 4, 16, 15, 64, 960, 945, 907200, 3628800
9: 1, 2, 4, 16, 15, 64, 960, 945, 3780, 3628800
9: 1, 2, 4, 16, 15, 64, 960, 945, 3840, 3628800
N=11
9: 1, 2, 4, 16, 20, 320, 324, 6480, 6160, 39916800
9: 1, 2, 3, 9, 81, 80, 77, 720, 518400, 39916800
9: 1, 2, 3, 9, 81, 80, 77, 720, 55440, 39916800
9: 1, 2, 3, 9, 81, 80, 77, 6400, 492800, 39916800
9: 1, 2, 3, 9, 81, 80, 77, 6400, 518400, 39916800
9: 1, 2, 3, 9, 81, 80, 77, 6480, 498960, 39916800
9: 1, 2, 3, 9, 81, 80, 77, 6480, 518400, 39916800
9: 1, 2, 3, 9, 81, 80, 77, 6237, 498960, 39916800
9: 1, 2, 3, 9, 81, 80, 77, 6237, 6400, 39916800
9: 1, 2, 3, 9, 81, 80, 77, 6160, 492800, 39916800
9: 1, 2, 3, 9, 81, 80, 77, 6160, 498960, 39916800
9: 1, 2, 3, 9, 81, 80, 77, 6160, 6480, 39916800
N=12
10: 1, 2, 4, 6, 24, 30, 720, 900, 924, 518400, 479001600
10: 1, 2, 4, 6, 24, 30, 900, 924, 576, 532224, 479001600
10: 1, 2, 4, 6, 24, 30, 900, 924, 576, 518400, 479001600
10: 1, 2, 4, 6, 24, 30, 900, 924, 720, 518400, 479001600
10: 1, 2, 4, 6, 24, 30, 900, 924, 720, 665280, 479001600
10: 1, 2, 4, 6, 12, 144, 150, 154, 20736, 3193344, 479001600
10: 1, 2, 4, 6, 12, 144, 150, 154, 20736, 3110400, 479001600
10: 1, 2, 4, 6, 36, 144, 150, 154, 20736, 3193344, 479001600
10: 1, 2, 4, 6, 36, 144, 150, 154, 20736, 3110400, 479001600
10: 1, 2, 4, 6, 24, 144, 150, 154, 20736, 3193344, 479001600
10: 1, 2, 4, 6, 24, 144, 150, 154, 20736, 3110400, 479001600
10: 1, 2, 4, 6, 12, 144, 150, 154, 21600, 3326400, 479001600
10: 1, 2, 4, 6, 12, 144, 150, 154, 21600, 3110400, 479001600
10: 1, 2, 4, 6, 12, 144, 150, 154, 22176, 3326400, 479001600
10: 1, 2, 4, 6, 12, 144, 150, 154, 22176, 3193344, 479001600
10: 1, 2, 4, 6, 12, 144, 150, 154, 22176, 21600, 479001600
10: 1, 2, 4, 6, 12, 144, 150, 154, 23100, 3326400, 479001600
10: 1, 2, 4, 6, 12, 144, 150, 154, 23100, 20736, 479001600
10: 1, 2, 4, 6, 36, 144, 150, 154, 21600, 3326400, 479001600
10: 1, 2, 4, 6, 36, 144, 150, 154, 21600, 3110400, 479001600
10: 1, 2, 4, 6, 36, 144, 150, 154, 22176, 3326400, 479001600
10: 1, 2, 4, 6, 36, 144, 150, 154, 22176, 3193344, 479001600
10: 1, 2, 4, 6, 36, 144, 150, 154, 22176, 21600, 479001600
10: 1, 2, 4, 6, 36, 144, 150, 154, 23100, 3326400, 479001600
10: 1, 2, 4, 6, 36, 144, 150, 154, 23100, 20736, 479001600
10: 1, 2, 4, 6, 24, 144, 150, 154, 21600, 3326400, 479001600
10: 1, 2, 4, 6, 24, 144, 150, 154, 21600, 3110400, 479001600
10: 1, 2, 4, 6, 24, 144, 150, 154, 22176, 3326400, 479001600
10: 1, 2, 4, 6, 24, 144, 150, 154, 22176, 3193344, 479001600
10: 1, 2, 4, 6, 24, 144, 150, 154, 22176, 21600, 479001600
10: 1, 2, 4, 6, 24, 144, 150, 154, 23100, 3326400, 479001600
10: 1, 2, 4, 6, 24, 144, 150, 154, 23100, 20736, 479001600
10: 1, 2, 4, 6, 24, 30, 900, 924, 21600, 19958400, 479001600
10: 1, 2, 4, 6, 24, 30, 900, 924, 21600, 518400, 479001600
10: 1, 2, 4, 6, 24, 30, 900, 924, 22176, 19958400, 479001600
10: 1, 2, 4, 6, 24, 30, 900, 924, 22176, 532224, 479001600
10: 1, 2, 4, 6, 24, 30, 900, 924, 22176, 21600, 479001600
10: 1, 2, 4, 6, 24, 30, 900, 924, 831600, 19958400, 479001600
10: 1, 2, 4, 6, 24, 30, 900, 924, 831600, 576, 479001600