1470 珍珠项链
Submit solution
Points:
100
Time limit:
1.0s
Memory limit:
32M
Problem types
Allowed languages
C, C++, Java, Python
Description
珍珠项链是一条有若干颗珍珠首尾相连的环。
给定项链的长度s和可选的珍珠颜色种数c,问最多有多少种互不相同的项链。
两条项链相同当且仅当其中一条通过翻转、旋转等操作后与另外一条项链的珍珠颜色序列相同。
Input
每行包含两个整数:可选珍珠的颜色种数c、项链长度s(c和s都是正整数,且c*s<=32)。
当c=s=0时终止。
Output
对每组输入数据,输出一行结果。
Sample
Input
1 1
2 1
2 2
5 1
2 5
2 6
6 2
0 0
Output
1
2
3
5
8
13
21
Source: Boski.Jr
Comments