POJ 2369】的更多相关文章

We remind that the permutation of some final set is a one-to-one mapping of the set onto itself. Less formally, that is a way to reorder elements of the set. For example, one can define a permutation of the set {1,2,3,4,5} as follows:  This record de…
傻逼图论. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define maxv 1050 #define maxn 1050 #define maxe 2050 using namespace std; ,g[maxv],ans[maxn],sum=,cnt=; bool vis[maxn]; struct edge { int v,nxt; }e[ma…
题目链接 给一个数列, 求这个数列置换成1, 2, 3....n需要多少次. 就是里面所有小的置换的长度的lcm. #include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <map> #include <set> #inclu…
寻找循环节求lcm够了,如果答案是12345应该输出1.这是下一个洞. #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<cmath> using namespace std; #define INF 0x3FFFFFF #define MAXN 2222 #define eps 1e-…
题意:给你一堆无序的数列p,求k,使得p^k=p 思路:利用置换的性质,先找出所有的循环,然后循环中元素的个数的lcm就是答案 代码: #include <cstdio> #include <cstring> #include <iostream> #define maxn 1234 using namespace std; int gcd(int a,int b) { ) return a; else return gcd(b,a%b); } int lcm(int…
Description We remind that the permutation of some final set is a one-to-one mapping of the set onto itself. Less formally, that is a way to reorder elements of the set. For example, one can define a permutation of the set {1,2,3,4,5} as follows:  Th…
Permutations Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3041   Accepted: 1641 Description We remind that the permutation of some final set is a one-to-one mapping of the set onto itself. Less formally, that is a way to reorder eleme…
题意 给定一个置换形式如,问经过几次置换可以变为恒等置换 思路 就是求k使得Pk = I. 我们知道一个置换可以表示为几个轮换的乘积,那么k就是所有轮换长度的最小公倍数. 把一个置换转换成轮换的方法也很简单,从一个数出发按照置换图置换,直到置换到已经置换过的数,则这些数就构成一个轮换. 代码 [cpp] #include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #i…
我们知道,当循环长度为L时,置换群幂次为K ,则结果是GCD(L,K)个积相乘. 于是,我们只需要求出每个循环的长度,求得它们的最小公倍数即为解. #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #define LL __int64 #define N 1000 using namespace std; int stack[N+1],top; int…
意图写出http://www.cnblogs.com/kuangbin/archive/2012/08/28/2661066.html这个东西的完善版. 1.置换,置换的运算 poj 2369 Permutations置换群中有一个定理:设T为一置换,e为单位置换,T^k=e,那么k的最小正整数解是T的拆分的所有循环长度的最小公倍数. #include <cstdio> ; ? a : gcd(b, a % b);} int lcm(int a,int b){return a / gcd(a,…