标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1727 Accepted Submission(s): 525
#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——————【规律+快速幂】
标签:
原文地址:http://www.cnblogs.com/chengsheng/p/4774637.html