置换群
lp_opai
我没有时间写一封简短的信,所以我写了一封长的。
展开
-
poj 3270 Cow Sorting (置换群)
/*对于每一个群,我们有两种换发:1.群里换,拿群里最小的数t与其他每个数交换,共k-1次,花费为:sum+(k-2)*t.2.将这个数列最小的数minn,拉入这个群,与该群最小的数t交换,然后用这个最小的数与其他数交换k-1次,然后再将minn与t换回来,这样花费为:sum+t+(k+1)*minn那么最小花费我们取两者中最小的,即sum+min{(k-2)*t,t+(k+1)*min原创 2014-09-02 14:02:45 · 819 阅读 · 1 评论 -
poj 2369 Permutations (置换群)
//问最少置换多少次变成有序序列//每个位置都有个循环节 求全部位置循环节的最小公倍数# include # include # include using namespace std;int gcd(int x,int y){ if(y==0) return x; return gcd(y,x%y);}int lcm(int x,int y){原创 2014-09-02 15:42:40 · 881 阅读 · 0 评论 -
poj 1721 CARDS (置换群)
//给出置换了s次后的序列,求原序列# include # include # include using namespace std;int main(){ int n,s,t,s1,i,cot; int a[1010],b[1010],c[1010]; while(~scanf("%d%d",&n,&s)) { for(i=1; i<原创 2014-09-02 19:56:52 · 683 阅读 · 0 评论 -
hdu 4529 Double Dealing (置换群)
# include # include # include using namespace std;__int64 gcd(__int64 a,__int64 b){ if(b==0) return a; return gcd(b,a%b);}int main(){ int n,k,i,j,vis[810],m,num[810],x;原创 2014-09-03 09:53:44 · 766 阅读 · 0 评论