首先,中心点是能够直接算出来的

把全部的坐标相加再除n就能够

然后枚举一个不靠近中心的点,枚举它绕中心点旋转的角度。仅仅要枚举50次就能够了

计算出当前枚举的的角度能否形成一个置换群

计算循环节,再用polya定理算个数

#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<cstring>
#include<iomanip>
using namespace std;
#ifdef _WIN32
#define i64 __int64
#define out64 "%I64d\n"
#define in64 "%I64d"
#else
#define i64 long long
#define out64 "%lld\n"
#define in64 "%lld"
#endif
/************ for topcoder by zz1215 *******************/
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define FOR(i,a,b) for( int i = (a) ; i <= (b) ; i ++)
#define FF(i,a) for( int i = 0 ; i < (a) ; i ++)
#define FFD(i,a,b) for( int i = (a) ; i >= (b) ; i --)
#define S64(a) scanf(in64,&a)
#define SS(a) scanf("%d",&a)
#define LL(a) ((a)<<1)
#define RR(a) (((a)<<1)+1)
#define pb push_back
#define pf push_front
#define X first
#define Y second
#define CL(Q) while(!Q.empty())Q.pop()
#define MM(name,what) memset(name,what,sizeof(name))
#define MC(a,b) memcpy(a,b,sizeof(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define read freopen("out.txt","r",stdin)
#define write freopen("out2.txt","w",stdout) const int inf = 0x3f3f3f3f;
const i64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
const double oo = 10e9;
const double eps = 10e-6;
const double pi = acos(-1.0);
const int maxn = 55;
const int mod = 1000000007; int n, m, c;
int nx[maxn];
int ny[maxn];
double cita[maxn];
double r[maxn];
double cx, cy;
int a[maxn];
int b[maxn];
int edge[maxn][maxn]; i64 gcd(i64 _a, i64 _b)
{
if (!_a || !_b)
{
return max(_a, _b);
}
i64 _t;
while ((_t = _a % _b))
{
_a = _b;
_b = _t;
}
return _b;
} i64 ext_gcd(i64 _a, i64 _b, i64 &_x, i64 &_y)
{
if (!_b)
{
_x = 1;
_y = 0;
return _a;
}
i64 _d = ext_gcd(_b, _a % _b, _x, _y);
i64 _t = _x;
_x = _y;
_y = _t - _a / _b * _y;
return _d;
} i64 invmod(i64 _a, i64 _p)
{
i64 _ans, _y;
ext_gcd(_a, _p, _ans, _y);
_ans < 0 ? _ans += _p : 0;
return _ans;
} double gao(double x,double y){
if (abs(x) < eps){
if (y>0){
return pi / 2.0;
}
else{
return pi + pi / 2.0;
}
}
else if (x >= 0 && y >= 0){
return atan(y / x);
}
else if (x <= 0 && y >= 0){
x = -x;
return pi - atan(y / x);
}
else if (x <= 0 && y <= 0){
x = -x;
y = -y;
return pi + atan(y / x);
}
else {
y = -y;
return 2 * pi - atan(y / x);
}
} int find(double tcita,double tr){
if (tcita > 2 * pi){
tcita -= 2 * pi;
}
double tx = cx + tr*cos(tcita);
double ty = cy + tr*sin(tcita);
for (int i = 1; i <= n; i++){
if (abs(tx - nx[i]) < eps && abs(ty-ny[i]) < eps){
return i;
}
}
return -1;
} bool isint(double temp){
int t2 = temp;
temp -= t2;
if (temp < eps) {
return true;
}
else{
return false;
}
} bool can(){
int now, to;
for (int x = 1; x <= n; x++){
for (int y = 1; y <= n; y++){
now = b[x];
to = b[y];
if (edge[x][y] != edge[now][to]){
return false;
}
}
}
return true;
} bool vis[maxn]; int count(){
MM(vis, 0);
int re = 0;
int now, to;
for (int x = 1; x <= n; x++){
if (!vis[x]){
now = x;
vis[now] = true;
re++;
while (true){
to = b[now];
if (vis[to]){
break;
}
else{
vis[to] = true;
now = to;
}
}
}
}
return re;
} i64 pow_mod(int x,int temp){
i64 re = 1;
for (int i = 1; i <= temp; i++){
re *= x;
re %= mod;
}
return re;
} i64 start(){
cx = 0.0;
cy = 0.0;
for (int i = 1; i <= n; i++){
cx += nx[i];
cy += ny[i];
}
cx /= n;
cy /= n;
double tx, ty;
for (int i = 1; i <= n; i++){
tx = nx[i] - cx;
ty = ny[i] - cy;
r[i] = sqrt(tx*tx + ty*ty);
cita[i] = gao(tx, ty);
}
double spin;
i64 ans = 0;
i64 sg =0;
int id;
for (int i = 1; i <= n; i++){
if (abs(cx - nx[i]) > eps || abs(cy - ny[i]) > eps){
id = i;
break;
}
}
for (int i = 1; i <= n; i++){
spin = cita[i] - cita[id];
if (abs(r[i] - r[id]) < eps){
bool no = false;
for (int x = 1; x <= n; x++){
a[x] = find(cita[x] + spin, r[x]);
if (a[x] == -1){
no = true;
break;
}
b[a[x]] = x;
}
if (no) continue;
if (can()){
sg++;
ans += pow_mod(c, count());
ans %= mod;
}
}
}
ans *= invmod(sg, mod);
ans %= mod;
return ans;
} int main(){
int T;
cin >> T;
while (T--){
cin >> n >> m >> c;
for (int i = 1; i <= n; i++){
cin >> nx[i] >> ny[i];
}
for (int i = 0; i <= n; i++){
for (int j = 0; j <= n; j++){
edge[i][j] = 0;
}
}
int now, to;
for (int i = 1; i <= m; i++){
cin >> now >> to;
edge[now][to] = edge[to][now] = 1;
}
if (n == 1){
cout << c << endl;
continue;
}
i64 ans = start();
cout << ans << endl;
}
return 0;
}

hdu 5080 2014ACM/ICPC鞍山K题 polya计数的更多相关文章

  1. hdu 5122(2014ACM/ICPC亚洲区北京站) K题 K.Bro Sorting

    传送门 对于错想成lis的解法,提供一组反例 1 3 4 2 5同时对于这次案例也可以观察出解法:对于每一个数,如果存在比它小的数在它后面,它势必需要移动,因为只能小的数无法向右移动,而且每一次移动都 ...

  2. HDU 5115 (2014ACM/ICPC亚洲区北京站) D题(Dire Wolf)

    题目传送门 设dp[i][j]为杀掉区间i到j之间的狼需要付出的最小代价,那么dp[i][j]=min{dp[i][k-1]+dp[k+1][j]+a[k]+b[i-1]+b[j+1]} Java代码 ...

  3. 2017 ACM/ICPC 沈阳 K题 Rabbits

    Here N (N ≥ 3) rabbits are playing by the river. They are playing on a number line, each occupying a ...

  4. hdu5080:几何+polya计数(鞍山区域赛K题)

    /* 鞍山区域赛的K题..当时比赛都没来得及看(反正看了也不会) 学了polya定理之后就赶紧跑来补这个题.. 由于几何比较烂写了又丑又长的代码,还debug了很久.. 比较感动的是竟然1Y了.. * ...

  5. HDU 5127.Dogs' Candies-STL(vector)神奇的题,set过不了 (2014ACM/ICPC亚洲区广州站-重现赛(感谢华工和北大))

    周六周末组队训练赛. Dogs' Candies Time Limit: 30000/30000 MS (Java/Others)    Memory Limit: 512000/512000 K ( ...

  6. HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)

    HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...

  7. HDU 5131.Song Jiang's rank list (2014ACM/ICPC亚洲区广州站-重现赛)

    Song Jiang's rank list Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java ...

  8. HDU 5135.Little Zu Chongzhi's Triangles-字符串 (2014ACM/ICPC亚洲区广州站-重现赛)

    Little Zu Chongzhi's Triangles Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 512000/512000 ...

  9. hdu 5868 Polya计数

    Different Circle Permutation Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K ...

随机推荐

  1. Qt学习博客推荐

    附录C Qt资源 C.1 Qt 官方资源 全 球各大公司以及独立开发人员每天都在加入 Qt 的开发社区.他们已经认识到了Qt 的架构本身便可加快应用程序开发进度.这些开发人员,无论是想开发单平台软件. ...

  2. 基本SQL语句练习(order by,group by,having)

    一.GROUP BY 和ORDER BY 1.使用Order by 进行排序,默认升序ASC,降序则使用DESC;(还可以这样:order by 1表示按第一列排序:order by 2 desc表示 ...

  3. springmvc的运行流程分析

    前几篇文章对springmvc讲解的很清楚,大家看下,有问题,我们再一起讨论. 其实springmvc最为重要是它的运行流程,接着,我们来分析一下,其运行过程,废话不多说,看图说话: 分析如下: 1, ...

  4. 自定义key解决zabbix端口监听取值不准确的问题

         今天有一个朋友问到我一个关于zabbix监控tcp端口的问题,明明端口在监听,但是通过net.tcp,listen取值取到的却是0. 经过简单的goole发现这已经是一个历史悠久的问题: 问 ...

  5. TravelCMS旅游网站系统前台诞生记-2(后台框架篇)

    经过一个多月的研发,前台页面已基本成型了,已开发了线路和签证两大模块,支持在线支付,微信支付待开发,在这个过程中,发现前端技术远比后台技术注重的细节多,特别是css,比我想象的要难,为了兼容各种浏览器 ...

  6. linux下登录出现-bash-3.2#解决办法

    1:下载 安装 csh yum  install csh   2:再切换即可  

  7. C# 导出word文档及批量导出word文档(4)

          接下来是批量导出word文档和批量打印word文件,批量导出word文档和批量打印word文件的思路差不多,只是批量打印不用打包压缩文件,而是把所有文件合成一个word,然后通过js来调用 ...

  8. Ueditor使用方法

    1.到百度下载文件,有各种版本.下载.net版本 2.将所需文件导入工程中 分别是:themes文件夹.third-party文件夹.ueditor.all.min.js.ueditor.config ...

  9. asp.net 发送邮件代码 System.Net.Mail

    前台页面 SendEmail.aspx 代码 using System.Net.Mail;using System.Net; <h2> 发送电子邮件演示 </h2> <t ...

  10. github 推送时can't be established.

    http://www.xuebuyuan.com/2095099.html 飞凡@FANZ /e/learngit (master)$ git push origin masterThe authen ...