hdu4365 Palindrome graph
Palindrome graph
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2118 Accepted Submission(s): 664Problem DescriptionIn 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?InputThere are several test cases.
For
each test case,there are three integer n m
k(0<n<=10000,0<=m<=2000,0<k<=1000000), indicate n*n
grid and k kinds of pigments.
Then follow m lines,for each line,there are 2 integer i,j.indicated that grid(i,j) (0<=i,j<n) has been filled with color.
You can suppose that jack have at least one way to paint a palindrome graph.OutputFor
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 Input3 0 24 2 31 13 1Sample Output83
1 #include<iostream>
2 #include<bits/stdc++.h>
3 #define MOD 100000007
4 using namespace std;
5 //map < pair <int ,int > ,int > mp; 既可以用mp来找,也可以用数组。测试表明,map内存开销更小
6 bool a[5050][5050]; //由于内存限制,数组开1/4大小就行
7 int cnt=0;
8 int quick_pow(int k,int x){
9 long long ans=1,base=k;
10 while(x!=0){
11 if(x&1==1){
12 ans=(ans*base)%MOD;
13 }
14 base=(base*base)%MOD;
15 x>>=1;
16 }
17 return (int)ans%MOD;
18 }
19 void change(int x,int y,int n){ //投影到同一区域
20 if(x>n-1-x){
21 x=n-1-x;
22 }
23 if(y>n-1-y){
24 y=n-1-y;
25 }
26 if(x>y){ //翻转操作
27 swap(x,y);
28 }
29 if(a[x][y]==0){
30 cnt++;
31 a[x][y]=1;
32 }
33 }
34 int main(){
35 int n,m,k;
36 while(scanf("%d%d%d",&n,&m,&k)!=EOF){
37 cnt=0;
38 //mp.clear();
39 memset(a,0,sizeof(a));
40 while(m--){
41 int x,y;
42 scanf("%d%d",&x,&y);
43 change(x,y,n);
44 }
45 int sum=0;
46 if(n%2==0){
47 sum=((1+n/2)*(n/2))/2;
48 }else{
49 sum=((1+(n+1)/2)*((n+1)/2))/2;
50 }
51 cout<<quick_pow(k,sum-cnt)<<endl;
52 }
53 return 0;
54 }
hdu4365 Palindrome graph的更多相关文章
- HDU 4365——Palindrome graph——————【规律+快速幂】
Palindrome graph Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- 2012 Multi-University #7
最短路+拆点 A As long as Binbin loves Sangsang 题意:从1走到n,每次都是LOVE,问到n时路径是连续多个"LOVE"的最短距离.秀恩爱不想吐槽. 分析:在普通的最 ...
- 2012 Multi-University Training Contest 7
2012 Multi-University Training Contest 7 A.As long as Binbin loves Sangsang B.Dead or alive C.Dragon ...
- 【LeetCode OJ】Palindrome Partitioning
Problem Link: http://oj.leetcode.com/problems/palindrome-partitioning/ We solve this problem using D ...
- [开发笔记] Graph Databases on developing
TimeWall is a graph databases github It be used to apply mathematic model and social network with gr ...
- PALIN - The Next Palindrome 对称的数
A positive integer is called a palindrome if its representation in the decimal system is the same wh ...
- Introduction to graph theory 图论/脑网络基础
Source: Connected Brain Figure above: Bullmore E, Sporns O. Complex brain networks: graph theoretica ...
- POJ 2125 Destroying the Graph 二分图最小点权覆盖
Destroying The Graph Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 8198 Accepted: 2 ...
- [LeetCode] Longest Palindrome 最长回文串
Given a string which consists of lowercase or uppercase letters, find the length of the longest pali ...
- [LeetCode] Palindrome Pairs 回文对
Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list, so that t ...
随机推荐
- 别再用 offset 和 limit 分页了,性能太差!
不需要担心数据库性能优化问题的日子已经一去不复返了. 随着时代的进步,随着野心勃勃的企业想要变成下一个 Facebook,随着为机器学习预测收集尽可能多数据的想法的出现. 作为开发人员,我们要不断地打 ...
- CodeForces 1367F1 Flying Sort (Easy Version)
题意 给一个长度为\(n\)的数组,数组中的数互不相同,你可以有两种操作 将某一个数放置在数组开头 将某一个数放置在数组结尾 问最小操作多少次可以得到一个递增数列 分析 因为数组中的数很大,我们可以将 ...
- QA|selenium在send_keys时报错dict object has no attribute ''|UI自动化测试
Q:selenium在send_keys时报错dict object has no attribute 'send_keys',如下图 增加了print(type(e1))发现确实是字典类型,怪了,按 ...
- 10款Visual Studio实用插件
前言 俗话说的好工欲善其事必先利其器,安装一些Visual Studio实用插件对自己日常的开发和工作效率能够大大的提升,避免996从选一款好的IDE实用插件开始.以下是我认为比较实用的Visual ...
- Dubbo3应用开发——架构的演变过程
Dubbo3应用开发--架构的演变过程 什么是Dubbo 早期Dubbo的定位: 基于Java的高性能,轻量级的RPC框架:SOA[Service-Oriented Architecture ⾯向服务 ...
- 炫酷转换:Java实现Excel转换为图片的方法
摘要:本文由葡萄城技术团队原创并首发.转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. 前言 在实际开发过程中,经常会有这样的需求:将Excel表格或特定区域 ...
- ESP32-MicroPython 开发环境
Linux/Mac 下使用MicroPython开发ESP32 刷入固件 使用 esptool.py 将 MicroPython 刷入 ESP32 开发板涉及几个步骤. 1. 安装 esptool 如 ...
- Kubernetes集群管理面板的安装及使用
Kubernetes集群管理面板的安装及使用 1.前言 若海的腾讯云Lighthouse组建跨地域Kubernetes集群,让我成功体验到了Kubernetes集群诸多优点,但是非技术出生的我,长时间 ...
- PTA乙级1038C++哈希解法
#include"bits/stdc++.h" using namespace std; int main() { int a,b[105]={0}; long i,n,K; ci ...
- 将.View.dll文件反编译出来的*Views*.cs文件转换成.cshtml
先使用反编译工具将.View.dll文件反编译放入文件夹,然后将文件夹整体复制进\src\viewcs2cshtml\viewcs2cshtml\bin\Debug\net6.0\viewcs 复制完 ...