热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

ACM快速幂模板HDU4365

ACM快速幂模板HDU4365快速幂模板:lintquick(lintbase,lintpow){lintret1;while(pow){if(pow&1)ret(ret*ba
ACM 快速幂模板 

HDU4365

//快速幂模板:
lint quick(lint base, lint pow)
{lint ret=1;while(pow){if (pow&1) ret=(ret*base)%mod;base=(base*base)%mod;pow>>=1;}return ret%mod;//记得最后mod,比如mod==1的情况
}


原题:

题解:http://www.cnblogs.com/bo-tao/archive/2012/08/15/2640380.html

/** Author: NICK WONG* Created Time: 2015/8/5 21:27:00* File Name: e.cpp*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define out(x) cout<<#x<<": "<const double eps(1e-8);
const int maxn&#61;10100;
const long long maxint&#61;-1u>>1;
const long long maxlong&#61;maxint*maxint;
typedef long long lint;
set > s;
int n,m;
lint k;
const long long mod&#61;100000007;void init()
{
}void change(int& x, int& y)
{if (x>n/2) x&#61;n&#43;1-x;if (y>n/2) y&#61;n&#43;1-y;if (x>y) swap(x,y);
}lint quick(lint base, lint pow)
{lint ret&#61;1;while(pow){if (pow&1) ret&#61;(ret*base)%mod;base&#61;(base*base)%mod;pow>>&#61;1;}return ret;
}void work()
{lint ans&#61;0;s.clear();for (int i&#61;1; i<&#61;(n&#43;1)/2; i&#43;&#43;)ans&#43;&#61;i;for (int i&#61;1; i<&#61;m; i&#43;&#43;){int x,y;cin>>x>>y;x&#43;&#43;; y&#43;&#43;;change(x,y);s.insert(make_pair(x,y));}ans-&#61;s.size();ans&#61;quick(k,ans);cout<}int main()
{while(cin>>n>>m>>k){init();work();}return 0;
}



E - Palindrome graph
Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u
Submit Status Practice HDU 4365


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<&#61;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-avatar
qm38dal
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有