青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

POJ 1026 Cipher

Cipher
Time Limit: 1000MS  Memory Limit: 10000K
Total Submissions: 12776  Accepted: 3194


Description
Bob and Alice started to use a brand-new encoding scheme. Surprisingly it is not a Public Key Cryptosystem, but their encoding and decoding is based on secret keys. They chose the secret key at their last meeting in Philadelphia on February 16th, 1996. They chose as a secret key a sequence of n distinct integers, a1 ; . . .; an, greater than zero and less or equal to n. The encoding is based on the following principle. The message is written down below the key, so that characters in the message and numbers in the key are correspondingly aligned. Character in the message at the position i is written in the encoded message at the position ai, where ai is the corresponding number in the key. And then the encoded message is encoded in the same way. This process is repeated k times. After kth encoding they exchange their message.

The length of the message is always less or equal than n. If the message is shorter than n, then spaces are added to the end of the message to get the message with the length n.

Help Alice and Bob and write program which reads the key and then a sequence of pairs consisting of k and message to be encoded k times and produces a list of encoded messages.

Input
The input file consists of several blocks. Each block has a number 0 < n <= 200 in the first line. The next line contains a sequence of n numbers pairwise distinct and each greater than zero and less or equal than n. Next lines contain integer number k and one message of ascii characters separated by one space. The lines are ended with eol, this eol does not belong to the message. The block ends with the separate line with the number 0. After the last block there is in separate line the number 0.

Output
Output is divided into blocks corresponding to the input blocks. Each block contains the encoded input messages in the same order as in input file. Each encoded message in the output file has the lenght n. After each block there is one empty line.

Sample Input
10
4 5 3 7 2 8 1 6 10 9
1 Hello Bob
1995 CERC
0
0

Sample Output
BolHeol  b
C RCE


Source
Central Europe 1995

給定1~n的置換F,求其變換m次的變換F^m.
先找到循環節,再用m對循環節的長度取模即可.

#include <iostream>
using namespace std;

int main()
{
    
const int MAX=300;//最大長度
    char str[MAX];//讀入串
    int n;//變換的長度
    
    
int data[MAX]={0};//存放原始變換
    int used[MAX]={0};//標志數組
    int cir[MAX][MAX]={0};//每個循環節的成員
    int num[MAX]={0};//循環節對應長度
    int cnt=0;//循環節的個數
    
    
int time=0;//變換次數
    int change[MAX]={0};//原始循環變換time次之后的變換
    
    
char res[MAX]={0};//變換之后的字符串
    
    

    
int i,j;
    
while(cin>>&& n)
    
{
        memset(used,
0,sizeof(used));
        memset(num,
0,sizeof(num));
        
for(i=1;i<=n;i++)
            cin
>>data[i];
        cnt
=0;//計數循環節個數
        for(i=1;i<=n;i++)
        
{
            
if(used[i]==0)
            
{
            
                used[i]
=1;
                
int temp=data[i];
                cir[cnt][num[cnt]]
=temp;
                num[cnt]
=1;
                
while(used[temp]==0)//獲得循環節
                {
                    used[temp]
=1;
                    temp
=data[temp];
                    cir[cnt][num[cnt]
++]=temp;    
                }

                cnt
++;
            }

        }
    
        
while(cin>>time && time)//讀入變換次數
        {
            memset(res,
0,sizeof(res));
            memset(str,
0,sizeof(str));
            gets(str);
            
int len=strlen(str);
            
for(i=len;i<=n;i++)//位數不足n,補空格
                str[i]=' ';

            
//獲得變換
            for(i=0;i<cnt;i++)
            
{
                
for(j=0;j<num[i];j++)
                
{
                    change[cir[i][j]]
=cir[i][(j+time)%num[i]];
                }

            }


            
//對讀入數據變換,獲得結果
            for(i=1;i<=n;i++)
            
{
                res[change[i]]
=str[i];
            }

            cout
<<res+1<<endl;    
        }

        cout
<<endl;

    }


    
    
return 0;
}

posted on 2010-08-25 09:29 若余 閱讀(556) 評論(0)  編輯 收藏 引用

導航

<2009年8月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
303112345

統計

常用鏈接

留言簿

隨筆檔案(16)

搜索

最新隨筆

最新評論

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            午夜视频一区| 另类成人小视频在线| 欧美一区二视频| 亚洲视频1区| 一区二区欧美激情| 一区二区三区四区五区精品视频| 亚洲精选在线观看| 在线亚洲+欧美+日本专区| 一本大道久久a久久精品综合 | 午夜一区二区三区在线观看| 亚洲欧美日韩直播| 久久精品夜色噜噜亚洲aⅴ| 久久精品亚洲国产奇米99| 久久国产精品久久国产精品| 久久美女性网| 欧美区一区二| 国产精品永久免费在线| 狠狠色狠狠色综合人人| 亚洲成人原创| 亚洲一区二区三区中文字幕在线| 先锋亚洲精品| 免费一级欧美片在线观看| 亚洲电影天堂av| 91久久久久| 午夜精品久久久久久久久久久久久 | 免费视频亚洲| 亚洲伦理中文字幕| 午夜国产精品视频免费体验区| 久久最新视频| 国产精品久久精品日日| 在线 亚洲欧美在线综合一区| 99视频在线精品国自产拍免费观看 | 免费一级欧美片在线播放| 亚洲理伦在线| 久久9热精品视频| 欧美精品在线一区二区| 精品成人一区二区| 先锋影院在线亚洲| 91久久在线观看| 久久国产精品久久久久久| 欧美视频福利| 性欧美18~19sex高清播放| 久久久噜噜噜久噜久久| 日韩一级精品视频在线观看| 久久久91精品国产一区二区三区 | 女女同性女同一区二区三区91| 国产精品成人观看视频免费| 影音先锋一区| 欧美一级黄色网| 夜久久久久久| 欧美精品在欧美一区二区少妇| 狠狠色丁香婷婷综合| 欧美在线观看一区| 亚洲最新视频在线播放| 欧美大胆a视频| 亚洲第一在线综合网站| 久久天堂国产精品| 性久久久久久久久久久久| 国产精品久久久久久久9999| 一本一本久久| 日韩午夜激情| 欧美日韩视频专区在线播放 | 中国日韩欧美久久久久久久久| 免费日韩成人| 久久久久久亚洲综合影院红桃| 国产性色一区二区| 久久精品一区蜜桃臀影院| 亚洲女人av| 国产欧亚日韩视频| 久久久久久久欧美精品| 久久久精品一区二区三区| 国产一区二区三区日韩欧美| 久久福利毛片| 欧美一区二区视频在线观看2020| 国产伦精品一区二区三区高清版 | 亚洲精品视频一区二区三区| 欧美国产一区视频在线观看| 91久久久久久久久| 亚洲精品乱码| 欧美亚韩一区| 欧美亚洲日本网站| 免费日韩av片| 国模大胆一区二区三区| 另类春色校园亚洲| 女人天堂亚洲aⅴ在线观看| 99视频精品全部免费在线| 亚洲人被黑人高潮完整版| 欧美日韩国产精品自在自线| 亚洲制服av| 久久精品91| 日韩视频一区二区三区| 一区二区三区免费看| 国产深夜精品| 欧美电影在线播放| 欧美天天综合网| 久久视频一区| 欧美精品99| 欧美中文在线视频| 免费观看日韩av| 亚洲欧美视频在线观看视频| 久久精品国产精品| 99re66热这里只有精品4| 亚洲欧美精品suv| 91久久香蕉国产日韩欧美9色| 一区二区三区高清| 伊人成人开心激情综合网| 亚洲级视频在线观看免费1级| 欧美午夜视频| 免费成人你懂的| 国产精品美女午夜av| 欧美福利一区二区| 国产精品xvideos88| 欧美成年人在线观看| 国产精品毛片va一区二区三区 | 国产午夜精品一区二区三区视频 | 亚洲人精品午夜| 国产一区二区三区久久 | 久久夜色精品一区| 欧美亚洲成人免费| 最新国产の精品合集bt伙计| 狠狠色狠狠色综合人人| 亚洲欧美日韩国产一区二区三区| 亚洲三级免费| 久久亚洲电影| 久久久久青草大香线综合精品| 欧美色区777第一页| 亚洲国产精品va在线看黑人| 国语精品一区| 欧美影院午夜播放| 欧美尤物一区| 国产精品日日摸夜夜添夜夜av| 亚洲人久久久| 亚洲日本va在线观看| 老司机一区二区三区| 久久蜜桃av一区精品变态类天堂| 国产精品日韩一区二区三区| 亚洲作爱视频| 性久久久久久久久| 久久精品国产亚洲高清剧情介绍| 亚洲视频狠狠| 欧美性理论片在线观看片免费| 亚洲国产三级| 亚洲欧洲精品一区二区三区波多野1战4| 欧美在线免费观看亚洲| 欧美在线视频一区二区| 国产日韩成人精品| 久久激情综合网| 免费在线看成人av| 亚洲国产精品女人久久久| 裸体一区二区| 亚洲成色www8888| 亚洲精品视频在线播放| 欧美久久久久| 亚洲视频在线观看视频| 欧美有码在线观看视频| 国产一区二区三区在线观看免费| 久久国内精品自在自线400部| 你懂的视频一区二区| 亚洲国产人成综合网站| 欧美激情综合五月色丁香| 99热这里只有精品8| 欧美一区二区三区免费在线看| 国产三区精品| 欧美成人亚洲| 亚洲视频一区二区在线观看| 久久国产精品亚洲va麻豆| 一区二区在线观看av| 欧美成人免费观看| 一区二区电影免费在线观看| 欧美中文字幕视频| 亚洲激情av在线| 欧美日韩综合精品| 欧美中文字幕视频在线观看| 麻豆91精品91久久久的内涵| 日韩视频在线观看一区二区| 国产精品久久久久久av下载红粉| 亚洲欧美国产另类| 欧美激情麻豆| 欧美一级电影久久| 亚洲乱码国产乱码精品精98午夜| 国产精品v欧美精品v日韩| 欧美在线观看你懂的| 亚洲精品一二区| 久久久久久亚洲精品中文字幕| 亚洲人体一区| 黄色成人在线| 国产精品老牛| 欧美激情亚洲精品| 欧美专区福利在线| 亚洲深夜福利在线| 亚洲大胆视频| 久久精品在线播放| 亚洲制服av| 一区二区高清视频| 亚洲国产精品久久久久秋霞不卡 | 欧美一区二区三区另类| 亚洲三级电影全部在线观看高清| 国产拍揄自揄精品视频麻豆| 欧美日本一区二区高清播放视频| 久久精品国产一区二区三|