编程介的小学生 2019-12-23 21:54 采纳率: 20.5%
浏览 134

Alphabet Soup 是怎么写的

Problem Description
Peter is having lunch at home. Unfortunately for him, today's meal is soup. As Peter's mother is aware that he doesn't like it very much, she has cooked a special soup using pasta pieces shaped like letters from the alphabet, numbers and other characters. She has a special knife with which she can prepare an unlimited supply of pasta pieces that may come in S different forms. The soup always has P pasta pieces in it, and is so thick that the pieces never move.
Despite her efforts, Peter is still not happy with today's menu and asks how many days in his life he will have to eat soup. His mother promises him that she will prepare a different soup every day, and that on no day will the dish contain the same shapes in all positions as any soup dish previously served. However, the number P of pasta pieces, as well as the positions in which pieces float, will remain the same every day. Peter is not easily fooled (or so he thinks), and he cleverly realizes that this can still make him eat soup for ages. In an attempt to reduce the number of configurations, he tells his mother he will not accept any dish which can be obtained by rotating one of the configurations previously seen.

Figure 1: Top view of Peter's dish

Consider the dish as a circle of radius 2 centered at the origin. All the symbols will be floating in the soup at a given angle (in millidegrees) at distance 1 from the origin. Two plates are considered equal if you can perform a rotation of one of the dishes about its center so that the positions of the symbols, as well as the symbols themselves, are the same in both.
Your program will be given the number of possible symbols Peter's mother has available, and the angles determining the location of each of the pasta pieces (measured clockwise in millidegrees). Write a program that returns the number of possible plates Peter's mother can prepare. As this number can be very large, output the number modulo 100,000,007, which is prime.

Input
The first line of input in each test case contains two numbers: S (2<=S<=1,000), the number of symbols Peter's mother can use; and P (P > 0), the number of pasta pieces floating in the soup. Each of the next P lines contain the angle A (0<=A <360,000) of one of the P pieces (measured clockwise in millidegrees). All angles will be different.
Different tests cases are separated by a blank line. After the last test case there is a line with S = P = -1.

Output
For each test case output a single integer in a line by itself, the number of different plates Peter's mother can cook modulo 100,000,007.

Sample Input
2 4
0
90000
180000
270000

100 5
0
45000
90000
180000
270000

-1 -1

Sample Output
6
99999307

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求解 yolo算法问题
    • ¥15 虚拟机打包apk出现错误
    • ¥30 最小化遗憾贪心算法上界
    • ¥15 用visual studi code完成html页面
    • ¥15 聚类分析或者python进行数据分析
    • ¥15 逻辑谓词和消解原理的运用
    • ¥15 三菱伺服电机按启动按钮有使能但不动作
    • ¥15 js,页面2返回页面1时定位进入的设备
    • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
    • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。