POJ 1026 Cipher Permutation Group

Source: Internet
Author: User

Test Instructions:Link Method:Permutation group parsing:Quite a simple permutation group? But the first time was too two to think wrong. I thought I was going to just follow that sequence and get the power of the permutation group OK. The results found that I did not affect this many loops-it is not funny. So hurry back and ask for a loop. For each of the intra-cycle permutations, the water problem is followed. Code:
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define Nusing namespace STD;intN,k;intA[n];intB[n][n];intV[n];CharTmp[n];CharPrint[n];intTotintLenth;voidGetn () {memset(V,0,sizeof(v)); for(intI=1; i<=n;i++) {intpt=i;if(!v[pt]) tot++;intCnt=0; while(!v[pt]) {v[pt]=1;            B[TOT][++CNT]=A[PT];         PT=A[PT]; }if(cnt!=0) b[tot][0]=cnt; }}intMain () { while(~scanf("%d", &n)) {if(n==0) Break; for(intI=1; i<=n;i++)scanf("%d", &a[i]); tot=0; GETN (); while(~scanf("%d", &k)) {if(k==0){printf("\ n"); Break;}Charuseless;scanf("%c", &useless); Gets (TMP);intlen=strlen(TMP); while(len<n) tmp[len++]="'; tmp[len]=' + '; for(intI=1; i<=tot;i++) { for(intj=1; j<=b[i][0];j++) {intTmp2= (j+k)%b[i][0];if(!TMP2) tmp2=b[i][0]; print[b[i][tmp2]-1]=tmp[b[i][j]-1]; }            } for(intI=0; i<n;i++) {printf("%c", Print[i]); }printf("\ n"); }    }}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

POJ 1026 Cipher Permutation Group

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.