UVA12600 Counting Necklaces

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=602&page=show_problem&problem=4278 [PDF](https://uva.onlinejudge.org/external/126/p12600.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12600/2460e2904e9849307eb4dbcf13ef6bba718b1e2b.png)

Input Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12600/f85f138ee3d33b0b0ea93054241a2c12981aae68.png)

Output Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12600/b7a41002714053eca550e8ddf042877a6ce0e1f5.png)