/**
题意: 给定一序列,置换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. Intellij Idea的一些配置

    1.字体 修改IDEA面板字体:Settings->Appearance-> Override default fonts by(not recommended)选中,选择自己喜欢的字体 ...

  2. TreeSet()详解

    TreeSet()详解   1.TreeSet原理:   /* * TreeSet存储对象的时候, 可以排序, 但是需要指定排序的算法 *  * Integer能排序(有默认顺序), String能排 ...

  3. Struts2配置问题java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

    方法一:右键点击项目--->build path-->configure build path-->左侧菜单栏就会看到Deployment Assembly-->右侧点击add ...

  4. linux系统find命令使用

    find命令简介 1.find的作用 find是个使用频率比较高的命令.常常用它在系统特定目录下,查找具有某种特征的文件. 2.    find命令的格式 find  [-path……]-option ...

  5. Nginx 拒绝指定IP访问

    来源 : http://www.ttlsa.com/nginx/nginx-deny-ip-access/   闲来无事,登陆服务器,发现有个IP不断的猜测路径.试图往服务器上传文件(木马).于是查看 ...

  6. jsp 配置MySQL服务器 以及数据的插入和读取

    不多说,直接上代码.百度上面也是一大堆,大家多问百度就行. 在利用JDBC访问数据库过程中,主要涉及三种资源:对数据库的连接的连接对象Connection,SQL语句对象 Statement,访问结果 ...

  7. SQLSERVER 使用WITH函数查找时间点最大数据行

      --表结构及数据: DTIME TYPE MONEY 2015-10-14 13:50:35.000 shopping 20 2015-10-21 13:51:24.000 shopping 40 ...

  8. fcntl记录锁

    #include<fcntl.h> int fcntl(fd,F_GETLK/F_SETLK/F_SETLKW,struct flock *flockptr); F_GETLK:测试flo ...

  9. gets和fgets函数的区别

    1. gets与fgets gets函数原型:char*gets(char*buffer);//读取字符到数组:gets(str);str为数组名. gets函数功能:从键盘上输入字符,直至接受到换行 ...

  10. selenium webdriver 学习笔记(一)

    selenium webdriver 第一个脚本: #coding = utf-8 from selenium import webdriver import time url = "htt ...