【Burnside引理】【Polya定理】Arif in Dhaka

Problem L

Arif in Dhaka (First LovePart 2)

Input: standard input

Output: standard output

Time Limit: 2 seconds

 

Our hero Arif is now in Dhaka (Lookat problem 10244– First Love if you want to know more about Arif, but thatinformation is not necessary for this problem. In short, Arif is a brilliantprogrammer working atIBM) and he islooking for his first love. Days pass by but his destiny theory is not workinganymore, which means that he is yet to meet his first love. He then decides toroam around Dhaka on arickshaw(A slow vehicle pulled by human power), running DFS (by physical movement) and BFS(with his eyes) on every corner of the street and market places to increase hisprobability of reaching his goal. While roaming around Dhaka he discovers an interestingnecklace shop. There he finds someinteresting necklace/braceletconstruction sets. He decides to buy some of them, but his programmer mindstarts looking for other problems. He wants to find out how many differentnecklace/bracelet can be made with acertain construction set. You are requested to help him again. The followingthings are true for anecklace/braceletconstruction set.

 

a)      All necklace/braceletconstruction sets has a frame, which hasNslots to place N beads.

b)      All the slots must be filled to make a necklace/bracelet.

c)      There are t types of beads in a set. Nbeads of each type are there in the box. So the total number of beads istN (t multiplied by N), ofwhich exactlyN can be used at atime.

 


Fig: Different types ofnecklace for t=2 and different value of N

 

The figure above shows necklaces for some different values of N (Here,t is always 2). Nowlet’s turn out attentions tobracelets.A bracelet is a necklacethat can be turned over (A junior programmer in Bangladesh says that wristwatch is anecklace (Boys!!! Don’tmind :-))). So for a bracelet thefollowing two arrangements are equivalent. Similarly, all other oppositeorientation or mirror images are equivalent.

 

 

So, given the description of a necklace/braceletconstruction set you will have to determine how many different necklace andbracelet can be formed with made with that set 

 

Input

The input file contains severallines of input. Each line contains two positive integersN(0<N<51)and t(0<t<11) as described inthe problem statement. Also note that within this input range inputs will besuch that no final result will exceed11digits. Input is terminated by end of file.  

 

Output

For each line of input produceone line of output which contains two round numbersNN and NB separated by asingle space, where NN is the numberof total possible necklaces and NBis the number of total possible bracelets for the corresponding input set. 

 

Sample Input

5 2

5 3

5 4

5 5

 

SampleOutput

8 8

51 39

208 136

629 377

有两种置换:旋转和翻转

讨论旋转:n为奇数或偶数是一样的。

而旋转(把本来的看作旋转次数为0)可以是1个间隔,2个间隔......n-1个间隔。即有n种置换(暂讨论旋转)。

假设某个置换,每个珠子旋转i个间隔,可以证明,这个置换中每个循环包含n/gcd(i,n)个元素,因此,这个置换有gcd(i,n)个循环。

不动点的总数为Σ(i=0,n-1) (k^(gcd(i,n)))。(暂讨论旋转)



讨论翻转:

当n为奇数,只有穿过一个点和另一条边的中点的对称轴。一共有n条,即有n种置换。

对于每种置换,都有(n-1)/2个两个元素的循环和一个1个元素的循环,共(n+1)/2个循环。不动点数为n*k^((n+1)/2)


当n为偶数,有穿过两个点的对称轴和不穿过点的对称轴。

前者:n/2种置换。每种置换n/2+1个循环。不动点数为n/2*t^(n/2+1)

后者:n/2种置换。每种置换n/2个循环。不动点数为n/2*t^(n/2)


根据Burnside引理,求一下平均值即为答案。


#include <cstdio>
#include <iostream>
using std::cin;
using std::cout;

typedef long long ll;
ll power[27];

int gcd(int a,int b)
{
	//cout << "gcd(" << a << "," << b << ")=";
	while (b)
	{
		int t = b;
		b = a%b;
		a = t;
	}
	//cout << a << '\n';
	return a;
}

int main()
{
	freopen("10294.in","r",stdin);
	freopen("10294.out","w",stdout);

	int n,t;
	while (scanf("%d%d",&n,&t)!=EOF)
	{
		power[0] = 1;
		for (int i=1;i<=n;i++)
			power[i] = power[i-1] * t;

		ll a = 0;
		ll b = 0;
		for (int i=0;i<n;i++)
		{
			a += power[gcd(i,n)];
		}
		if (n & 1)
		{
			b = n * power[(n+1)>>1];
		}
		else
		{
			b = n/2*power[n/2+1] + n/2*power[n/2];
		}

		cout << a/n << " " << (a+b)/2/n << "\n";
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这是一个组合数学问题,我们可以使用 Burnside 引理来解决。Burnside 引理是一个计数定理,可以用于计算一个群在一些操作下的不动点个数。 对于这个问题,我们可以使用置换群 $S_n$,它包含 $n!$ 个置换,每个置换都对应着集合 $A$ 上的一个等价关系。我们需要计算的是在这 $n!$ 个置换中有多少个是等价的。 对于一个置换 $\sigma \in S_n$,我们定义它的循环节数为 $\operatorname{lcm}(k_1, k_2, \ldots, k_m)$,其中 $k_1, k_2, \ldots, k_m$ 是 $\sigma$ 的所有循环的长度。例如,对于置换 $(1\ 2\ 3)(4\ 5)$,它的循环节数为 $\operatorname{lcm}(3, 2) = 6$。 根据 Burnside 引理,不同等价关系的个数等于所有置换的循环节数的平均数。也就是说,我们需要计算: $$ \frac{1}{n!} \sum_{\sigma \in S_n} \operatorname{lcm}(k_1, k_2, \ldots, k_m) $$ 其中 $k_1, k_2, \ldots, k_m$ 是 $\sigma$ 的所有循环的长度。这个式子看起来很难计算,但是我们可以使用 Polya 定理来简化它。 Polya 定理是一个计数定理,可以用于计算一个群在一些操作下的循环节数。我们在这里简单介绍一下它的用法。对于一个置换群 $G$,我们可以定义它的一个操作为一个二元组 $(g, x)$,其中 $g \in G$,$x$ 是一个元素。这个操作将 $x$ 变成 $g(x)$。我们需要计算 $G$ 在所有操作下的不动点个数之和。根据 Polya 定理,这个和等于 $$ \frac{1}{|G|} \sum_{g \in G} a(g)^{c(g)} $$ 其中 $a(g)$ 是 $g$ 操作下的不动点个数,$c(g)$ 是 $g$ 的循环节数。 对于这个问题,我们可以使用 $S_n$ 的所有置换作为操作。对于一个置换 $\sigma \in S_n$,我们将它表示成一个 $n$ 元组 $(a_1, a_2, \ldots, a_n)$,其中 $a_i$ 是 $\sigma(i)$。我们定义操作 $(\tau, (a_1, a_2, \ldots, a_n))$ 将元组 $(a_1, a_2, \ldots, a_n)$ 变成 $(\tau(a_1), \tau(a_2), \ldots, \tau(a_n))$。 我们需要计算 $S_n$ 在所有操作下的不动点个数之和。根据 Polya 定理,这个和等于 $$ \frac{1}{n!} \sum_{\sigma \in S_n} 2^{c(\sigma)} $$ 其中 $c(\sigma)$ 是 $\sigma$ 的循环节数。注意到这个式子只和 $\sigma$ 的循环节数有关,不和具体的置换有关。因此,我们可以将它改写成 $$ \frac{1}{n!} \sum_{k=1}^n p(n, k) 2^{k} $$ 其中 $p(n, k)$ 表示将 $n$ 个元素划分成 $k$ 个非空的循环的方案数。它的值可以使用 Bell 数来计算。也就是说, $$ p(n, k) = \sum_{i=0}^k {k \choose i} B_{n-i} $$ 其中 $B_n$ 是第 $n$ 个 Bell 数。它的递推式是 $$ B_{n+1} = \sum_{k=0}^n {n \choose k} B_k $$ 边界条件是 $B_1 = 1$。 综上所述,我们可以使用下面的 Python 代码来解决这个问题:

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值