poj 1721 CARDS (置换群)
来源:互联网 发布:内衣品牌推荐 知乎 编辑:程序博客网 时间:2024/06/14 03:27
//给出置换了s次后的序列,求原序列# include <stdio.h># include <algorithm># include <string.h>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<=n; i++) { scanf("%d",&a[i]); b[i]=a[i]; c[i]=a[i]; } cot=0; while(1)//求循环节 { cot++; for(i=1; i<=n; i++) b[i]=c[c[i]]; for(i=1; i<=n; i++) { if(a[i]!=b[i]) break; } if(i>n) break; for(i=1; i<=n; i++) c[i]=b[i]; } s%=cot; s=cot-s; while(s--) { for(i=1; i<=n; i++) b[i]=a[a[i]]; for(i=1; i<=n; i++) a[i]=b[i]; } for(i=1; i<=n; i++) printf("%d\n",b[i]); } return 0;}
0 0
- poj 1721 CARDS (置换群)
- poj 1721 CARDS (置换群)
- POJ 1721 - CARDS【置换群】
- POJ 1721 CARDS 置换群
- POJ 1721CARDS <置换群>
- poj 1721 CARDS(置换)
- POJ 1721 CARDS(置换)
- 【POJ 1721】CARDS(置换群)
- 【POJ】1721 - CARDS(置换群)
- POJ 1721 CARDS (置换群)
- poj 1721 CARDS(置换)
- [置换开方] POJ 1721 CARDS
- poj 1721 CARDS(置换群的幂运算)
- POJ 1721 CARDS(置换+循环节)
- POJ 1721-CARDS(置换群-单个循环置换幂运算 倒推)
- POJ 1271 CARDS 置换/循环节/置换群开方
- poj 1721 CARDS 【置换群 】【求最小循环节 再由末序列 求 初序列】
- CARDS----置换
- MapReduce(十七): MR的访问控制
- 单例模式的使用
- 关于Java集合最被关注的10 个问题
- cocos2d 人物缩小和放大以及人物移动,重复运动,组合动作
- HDU 3917 Road constructions(最小割---最大权闭合)
- poj 1721 CARDS (置换群)
- conversion to dalvik format failed with error 1
- Spring中@component注解
- [寒江孤叶丶的Cocos2d-x之旅_12]浅谈Cocos2d-x中的内置粒子效果,和粒子的plist的导入
- 黑马程序员——Java集合框架—概述
- 【iOS】UICollectionView自定义Layout之蜂窝布局
- 引导加载程序之争:了解 LILO 和 GRUB
- poj上 G++ GCC C++编译器的区别?
- 设计模式--桥接模式