/**
题意: 给定一序列,置换k次之后 输出其状态
置换: 考察循环节长度,
思路: 分别求出每个元素的循环节的大小,用k 模其大小,大的k次之后的位置, 输出即可
**/ #include <iostream>
#include <cstring>
#include <cstdio>
using namespace std; int main()
{
int n;
int sec[];
int path[][];
int len[];
while(cin>>n&&n){
memset(path,,sizeof(path));
memset(len,,sizeof(len));
int t;
for(int i=;i<n;i++){
cin>>t;
sec[i] = t-;
}
for(int i=;i<n;i++){
int j= i;
path[i][] = j;
len[i] = ;
for(j=sec[j];j!=i;j=sec[j])
path[i][len[i]++] = j;
}
int k;
char str[];
while(cin>>k&&k){
getchar();
gets(str);
char res[];
//int len = strlen(str);
int m=;
for(;str[m];m++);
for(int j=m;j<n;j++)
str[j]=' ';
for(int i=;i<n;i++)
res[path[i][k%len[i]]] = str[i];
res[n]='\0';
cout<<res<<endl;
}
cout<<endl;
}
return ;
}

poj 1206的更多相关文章

  1. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  2. 【转】POJ百道水题列表

    以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...

  3. 51nod 1206:Picture 求覆盖周长

    1206 Picture 题目来源: IOI 1998 基准时间限制:2 秒 空间限制:131072 KB 分值: 160 难度:6级算法题  收藏  关注 给出平面上的N个矩形(矩形的边平行于X轴和 ...

  4. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  5. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  6. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  7. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  8. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  9. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

随机推荐

  1. LocalStorage存储

     1.localStorage存储服务: .factory('storageSvc', [function () { return { //保存数据 save: function (key, valu ...

  2. javascript 学习笔记(权威指南)

    1.数组的sort()方法默认是按照字母排序的,下面举个栗子说明: 1)全是字母: var arr =["zu","fan","an",&q ...

  3. Ajax中send方法的使用

    Ajax中send方法参数的使用 一般情况下,使用Ajax提交的参数多是些简单的字符串,可以直接使用GET方法将要提交的参数写到open方法的url参数中,此时send方法的参数为null. 例如 : ...

  4. zend framework virtualhost设置方法

    Phpunit 的用法 php phpunit.phar 就可以运行phpunit了 修改本地域名vhost F:\Tools\wamp\bin\apache\apache2.4.9\conf\ext ...

  5. php curl函数实例

    <?php function login(){ $url = 'http://jspatch.qq.com/offline/check?qver=6.2.0.427&hver=0& ...

  6. 在Win7的IIS上搭建FTP服务及用户授权——转载!!

    原文地址:http://blog.sina.com.cn/s/blog_6cccb1630100q0qg.html FTP服务 FTP是文件传输协议(File Transfer Protocol)的简 ...

  7. skynet初学

    记录下命令 git clone https://github.com/cloudwu/skynet.git sudo apt-get install autoconf sudo apt-get ins ...

  8. Ubuntu安装JDK(tar.gz)

    如果没有创建root用户: sudo passwd root 在oracle官网下载jdk(百度"JDK")的tar.gz包: jdk-7u55-linux-x64.gz 这是我下 ...

  9. Visual Studio 2008中控制台程序一闪而过的解决方法

    VS2008中编写C/C++的程序时,调试运行,控制台窗口会在执行完毕后立即关闭,这样就无法看到运行的结果.为了解决这个问题,可以使用①system("pause"); ②getc ...

  10. JavaScript和php常用语法——切割字符串

    在面向Web的应用中,前台和后台通信非常常用的一种格式就是字符串,所以,在通信中,我们不可避免的就需要进行字符串的拼切. 在js代码中,当我们传递一个字符串到后台代码时,我们在后台需要对字符串进行切割 ...