HDU 4365——Palindrome graph——————【规律+快速幂】
Palindrome graph
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1727    Accepted Submission(s): 525
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?
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.
#include<bits/stdc++.h>
using namespace std;
const int mod=1e8+7;
typedef __int64 INT;
map<pair<int,int>,int>mp;
int Pow(INT x,int nn){
INT ret=1;
while(nn){
if(nn&1)
ret=ret*x%mod;
x=x*x%mod;
nn>>=1;
}
return ret;
}
int main(){
int n,m,k,x,y;
while(scanf("%d%d%d",&n,&m,&k)!=EOF){
mp.clear();
int pted=0,cnt=0;
while(m--){
scanf("%d%d",&x,&y);
if(x>n-1-x){ //坐标转化成三角形中的对称坐标
x=n-1-x;
}
if(y>n-1-y){
y=n-1-y;
}
if(x>y){
swap(x,y);
}
if(mp[make_pair(x,y)]==0){
mp[make_pair(x,y)]=1;
pted++;//已经涂过色的
}
}
int cc=(n+1)/2;
cnt=(cc+1)*cc/2; //三角形中的总格子数
INT ans=Pow((INT)k,(cnt-pted));
printf("%I64d\n",ans);
}
return 0;
}
HDU 4365——Palindrome graph——————【规律+快速幂】的更多相关文章
- HDU.1575 Tr A ( 矩阵快速幂)
		
HDU.1575 Tr A ( 矩阵快速幂) 点我挑战题目 题意分析 直接求矩阵A^K的结果,然后计算正对角线,即左上到右下对角线的和,结果模9973后输出即可. 由于此题矩阵直接给出的,题目比较裸. ...
 - hdu 3117 Fibonacci Numbers 矩阵快速幂+公式
		
斐波那契数列后四位可以用快速幂取模(模10000)算出.前四位要用公式推 HDU 3117 Fibonacci Numbers(矩阵快速幂+公式) f(n)=(((1+√5)/2)^n+((1-√5) ...
 - HDU 5793 A Boring Question (找规律 : 快速幂+逆元)
		
A Boring Question 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5793 Description Input The first l ...
 - hdu 5187 zhx's contest [ 找规律 + 快速幂 + 快速乘法  ||  Java ]
		
传送门 zhx's contest Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
 - HDU 5607 graph 矩阵快速幂 + 快速幂
		
这道题得到了学长的助攻,其实就是一个马尔科夫链,算出一步转移矩阵进行矩阵快速幂就行了,无奈手残 这是我第一回写矩阵快速幂,写的各种毛病,等到调完了已经8点44了,交了一发,返回PE,(发现是少了换行) ...
 - HDU 2842 (递推+矩阵快速幂)
		
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2842 题目大意:棒子上套环.第i个环能拿下的条件是:第i-1个环在棒子上,前i-2个环不在棒子上.每个 ...
 - HDU - 1005 Number Sequence 矩阵快速幂
		
HDU - 1005 Number Sequence Problem Description A number sequence is defined as follows:f(1) = 1, f(2 ...
 - hdu 2604 Queuing(矩阵快速幂乘法)
		
Problem Description Queues and Priority Queues are data structures which are known to most computer ...
 - ACM-ICPC 2018 焦作赛区网络预赛 G. Give Candies (打表找规律+快速幂)
		
题目链接:https://nanti.jisuanke.com/t/31716 题目大意:有n个孩子和n个糖果,现在让n个孩子排成一列,一个一个发糖果,每个孩子随机挑选x个糖果给他,x>=1,直 ...
 
随机推荐
- ListView 动态生成 Header
			
//取得结果集 DataTable dt = ub.GetUser().Tables[0]; //清空原本的内容 listView1.Items.Clear(); //通过DataTable 得到当前 ...
 - CodeSmith链接MySQL
			
环境:Win7 x64 旗舰版 CodeSmith Generator Professional 6.5.0 MySQL 5.6.17 x64 在CodeSmith中按一般步骤创建数据库连接 Data ...
 - JavaScript混淆压缩
			
比较好用的压缩软件,支持合并 JsCompressor-v3.0 比较好用的混淆站点:http://dean.edwards.name/packer/
 - Linux之创建777权限的文件
			
服务器中运行项目的时候,有时候会出现图片上传失败,查看报错原因才知道是文件夹没有写入权限导致上传失败. 方案1: 在使用Linux命令更改对应目录的权限 方案2: 在代码中创建文件夹的时候给予对应的7 ...
 - Generic detail view PostDetailView must be called with either an object pk or a slug.解决
			
Django 使用DetailView有这个问题,url,和模板统一调用模型时,用pk,而不是id 如果不是用DetailView,只是简单的视图,则用pk 或者id都可以. urls.py: url ...
 - linux 基本概念
			
Linux把物理内存分为了固定统一大小的块,称为page(页框),一般为4KB. Linux采用4KB页框大小作为标准的物理内存分配单元,内核用数据结构page描述一个页框的状态信息,其实页是进程的概 ...
 - FPGA基础学习(1) -- FFT IP核(Quartus)
			
为了突出重点,仅对I/O数据流为steaming的情况作简要说明,以便快速上手,有关FFT ip核模型及每种设置详细介绍请参考官方手册FFT MegaCore Function User Guide. ...
 - pytorch tensor与numpy转换
			
从官网拷贝过来的,就是做个学习记录.版本 0.4 tensor to numpy a = torch.ones(5) print(a) 输出 tensor([1., 1., 1., 1., 1.]) ...
 - SwiftMailer 发送邮件时 提示fsockopen() 被禁用
			
站点转移空间,发送邮件的SwiftMailer 类提示错误如下: Warning: fsockopen() has been disabled for security reasons in D:\1 ...
 - 浅谈c语言的线性表的基本操作———基于严蔚敏的数据结构(c语言版)
			
主要讲的是线性表的创建,插入及删除: 0. 线性表的建立,对于这类操作主要是利用了结构体的性质,对于定义的线性表的特性主要有三点:首先 Typedef struct { ElemType *ele ...