电子游戏晶体管具有非常有趣的能力系统。您收集了16个“功能”,可以在16个不同的插槽中使用。有趣的是,有3种插槽类型,每个函数根据您在哪个插槽中使用其行为有所不同:
- 有4个被动插槽。
- 有4个活动插槽。
- 每个活动插槽都有2个升级插槽。
我们想弄清楚给我们带来了多少种不同的技能。
但是,某些组合是等效的。特别是,在这些插槽组的每一个中,功能的特定位置无关紧要。另一方面,升级插槽中功能的效果确实取决于父级活动插槽中使用的特定功能。
因此,使用十六进制数字表示功能,以下组合都是等效的:
Passive Slots: 0 1 2 3
Active Slots: 4 5 6 7
Upgrade Slots: 8 9 A B C D E F
Passive Slots: 2 0 1 3 # Permutation of passive slots.
Active Slots: 4 5 6 7
Upgrade Slots: 8 9 A B C D E F
Passive Slots: 0 1 2 3
Active Slots: 5 6 4 7 # Permutation of active slots together
Upgrade Slots: A B C D 8 9 E F # with their upgrade slots.
Passive Slots: 0 1 2 3
Active Slots: 4 5 6 7
Upgrade Slots: 8 9 B A C D F E # Permutation within upgrade slots.
以及这些重排的任何组合。请注意,在第三种情况下,升级插槽与活动插槽一起交换,以保持相同的总体效果。
另一方面,以下组合均与上述组合不同:
Passive Slots: 4 5 6 7 # Passive slots swapped
Active Slots: 0 1 2 3 # with active slots.
Upgrade Slots: 8 9 A B C D E F
Passive Slots: 0 1 2 3
Active Slots: 5 4 6 7 # Permutation of active slots without
Upgrade Slots: 8 9 A B C D E F # changing upgrade slots.
Passive Slots: 0 1 2 3
Active Slots: 4 5 6 7
Upgrade Slots: 8 A 9 B C D E F # Permutation between different upgrade slots.
根据我的计算,假设所有功能都使用,则可以为您提供2,270,268,000个(功能上不同的)组合。
如果您可使用的功能少于16个,则某些插槽将保留为空。但是,请注意,如果父级活动插槽为空,则不能在升级插槽中放置功能。
挑战
您要根据拥有的功能来确定可能的配置数量。此外,为了避免琐碎的硬编码解决方案,我将通过使插槽数可变来稍微推广该问题。
编写一个程序或函数,给定两个正整数M ≥ 1
和1 ≤ N ≤ 4M
,并假设完全N
不同的功能用于填充尽可能多的M
被动,M
主动和2M
升级插槽,确定可能的(功能上不同的)技能集的数量。
您可以编写程序或函数,通过STDIN(或最接近的替代方案),命令行参数或函数自变量获取输入,并通过STDOUT(或最接近的替代方案),函数返回值或函数(out)参数输出结果。
您的代码必须能够M = 8
在一台合理的台式机上在一分钟之内(包括一分钟)处理所有输入。在这方面有一些余地,但是应该排除蛮力解决方案。原则上,在不到一秒钟的时间内解决这些输入中的任何一个都不应该成为问题。
这是代码高尔夫球,最短的答案(以字节为单位)获胜。
测试用例
每个测试用例均采用形式M N => Result
。
1 1 => 2
1 2 => 4
1 3 => 9
1 4 => 12
2 1 => 2
2 2 => 6
2 3 => 21
2 4 => 78
2 5 => 270
2 6 => 810
2 7 => 1890
2 8 => 2520
3 1 => 2
3 2 => 6
3 3 => 23
3 4 => 98
3 5 => 460
3 6 => 2210
3 7 => 10290
3 8 => 44520
3 9 => 168840
3 10 => 529200
3 11 => 1247400
3 12 => 1663200
4 1 => 2
4 2 => 6
4 3 => 23
4 4 => 100
4 5 => 490
4 6 => 2630
4 7 => 14875
4 8 => 86030
4 9 => 490140
4 10 => 2652300
4 11 => 13236300
4 12 => 59043600
4 13 => 227026800
4 14 => 718918200
4 15 => 1702701000
4 16 => 2270268000
5 1 => 2
5 2 => 6
5 3 => 23
5 4 => 100
5 5 => 492
5 6 => 2672
5 7 => 15694
5 8 => 98406
5 9 => 644868
5 10 => 4306932
5 11 => 28544670
5 12 => 182702520
5 13 => 1101620520
5 14 => 6122156040
5 15 => 30739428720
5 16 => 136670133600
5 17 => 524885961600
5 18 => 1667284819200
5 19 => 3959801445600
5 20 => 5279735260800
6 1 => 2
6 2 => 6
6 3 => 23
6 4 => 100
6 5 => 492
6 6 => 2674
6 7 => 15750
6 8 => 99862
6 9 => 674016
6 10 => 4787412
6 11 => 35304654
6 12 => 265314588
6 13 => 1989295308
6 14 => 14559228684
6 15 => 101830348620
6 16 => 667943115840
6 17 => 4042651092480
6 18 => 22264427465280
6 19 => 110258471363040
6 20 => 484855688116800
6 21 => 1854067032417600
6 22 => 5894824418683200
6 23 => 14025616720315200
6 24 => 18700822293753600
7 1 => 2
7 2 => 6
7 3 => 23
7 4 => 100
7 5 => 492
7 6 => 2674
7 7 => 15752
7 8 => 99934
7 9 => 676428
7 10 => 4849212
7 11 => 36601554
7 12 => 288486132
7 13 => 2349550632
7 14 => 19504692636
7 15 => 162272450340
7 16 => 1328431104000
7 17 => 10507447510560
7 18 => 78942848624640
7 19 => 554967220167360
7 20 => 3604592589998400
7 21 => 21411337810262400
7 22 => 115428212139240000
7 23 => 561247297649438400
7 24 => 2439121536313862400
7 25 => 9283622495827680000
7 26 => 29520583763711040000
7 27 => 70328449554723360000
7 28 => 93771266072964480000
8 1 => 2
8 2 => 6
8 3 => 23
8 4 => 100
8 5 => 492
8 6 => 2674
8 7 => 15752
8 8 => 99936
8 9 => 676518
8 10 => 4852992
8 11 => 36722169
8 12 => 291621462
8 13 => 2418755196
8 14 => 20834571186
8 15 => 184894557705
8 16 => 1672561326150
8 17 => 15217247948760
8 18 => 137122338089880
8 19 => 1204392465876600
8 20 => 10153538495100000
8 21 => 81007229522419200
8 22 => 604136189949692400
8 23 => 4168645459350372000
8 24 => 26403795950145213600
8 25 => 152700324078982680000
8 26 => 803784718213396920000
8 27 => 3838761204861983400000
8 28 => 16503742828841748480000
8 29 => 62545434470667308160000
8 30 => 198853691115980300400000
8 31 => 474189571122722254800000
8 32 => 632252761496963006400000
这些是您的代码在一分钟内(每个)必须处理的所有输入,但是原则上它应该适用于较大的输入。您可以使用以下一些M = 10
测试用例进行检查:
10 1 => 2
10 2 => 6
10 3 => 23
10 4 => 100
10 5 => 492
10 6 => 2674
10 7 => 15752
10 8 => 99936
10 9 => 676520
10 10 => 4853104
10 11 => 36727966
10 12 => 291849866
10 13 => 2426074222
10 14 => 21033972388
10 15 => 189645995396
10 16 => 1773525588406
10 17 => 17155884420532
10 18 => 171073929494468
10 19 => 1750412561088334
10 20 => 18258387148774916
10 21 => 192475976310317700
10 22 => 2028834600633220380
10 23 => 21127206177119902860
10 24 => 214639961631544809360
10 25 => 2101478398293813739200
10 26 => 19602967930531817832000
10 27 => 172444768103233181556000
10 28 => 1417975382888905296456000
10 29 => 10820259026484304813416000
10 30 => 76213534343700480310584000
10 31 => 493916052421168703366040000
10 32 => 2941900199368102067135040000
10 33 => 16113144277547868007416960000
10 34 => 81222252655277786422930560000
10 35 => 376309102059179385262246080000
10 36 => 1589579966324953534441910400000
10 37 => 5981477408861097281112374400000
10 38 => 19005991357166148698688124800000
10 39 => 45381652832417130566255318400000
10 40 => 60508870443222840755007091200000
turn()
之后help()
再get()
回答load()
,否则在我和........ 之后我可能需要ping()
你...男人……void()
spark()
crash()
N
功能都在使用中。