作者:qm38dal | 来源:互联网 | 2023-10-10 08:37
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
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?
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.