Time Limit: 2000/1000 MS (
Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1306 Accepted Submission(s): 398
Problem Description
In addition fond of programing, Jack also loves painting. He likes to draw many interesting graphics on the paper.
One day,Jack found a new interesting graph called Palindrome graph. No matter how many times to flip or rotate 90 degrees, the palindrome graph are always unchanged.
Jack took a paper with n*n grid and K kinds of pigments.Some of the grid has been filled with color and can not be modified.Jack want to know:how many ways can he paint a palindrome graph
Input
There are several test cases.
For each test case,there are three integer n m k(0
Then follow m lines,for each line,there are 2 integer i,j.indicated that grid(i,j) (0<=i,j
You can suppose that jack have at least one way to paint a palindrome graph.
Output
For each case,print a integer in a line,indicate the number of ways jack can paint. The result can be very large, so print the result modulo 100 000 007.
Sample Input
3 0 2
4 2 3
1 1
3 1
Sample Output
8
3
Author
FZU
Source
2012 Multi-University Training Contest 7
题目大意:flip是翻转的意思,rotate是旋转的意思。就是说给你一个n*n的格子,然后每个格子图上任意颜色,但是通过翻转旋转必须一样。高度轴对称和中心对称。
解题思路:经过思考可以发现,我们将正方形先等分成四份,如果一份确定,其它三个必然确定。而一个小正方形中是否存在依赖关系呢,答案是肯定的。所以再将正方形细分为两个三角形即可,一个三角形确定,小正方形确定,大正方形也确定了。这是总数sum。而有一些是涂色了的,个数便会减少,但是可以经过变换等价的点只能计算一次,详见代码。
题目地址:Palindrome graph
一直以为是mod=1e9+7,这个题目竟然是1e8+7。 题目得看清!!
AC代码:
#include#include #include