poj1026
来源:互联网 发布:windows无法加载怎么办 编辑:程序博客网 时间:2024/04/29 21:12
题目大意:
Bob和Alice开始用一种崭新的编码方案。他们选择n个大于0小于等于n的序列a1 ; …; an。他们按照下列规则编码。消息在序列下马书写,所以字符和序列中的数字对齐,消息中的位置i的字符编码成位置ai的字符,整个过程迭代k次。如果消息长度小于n,后面用空格填补。
输入序列和消息,输出编码后的消息
解题思路:
模拟题,顺着来就可以了
代码如下:
#include<stdio.h>#include<string.h>#include<stdlib.h>int main(){ int n,i,k,x,m,t; int num[300]; char ch[300]; char re[300]; while(scanf("%d",&n)!=EOF&&n) { for(i=0;i<n;i++) { scanf("%d",&num[i]); num[i]--; } while(scanf("%d",&k)!=EOF&&k) { getchar(); gets(ch); if(strlen(ch)<n) { for(i=strlen(ch);i<n;i++) { ch[i]=' '; } } for(i=0;i<n;i++) { m=1; t=num[i]; while(i!=t) { t=num[t]; m++; } x=k%m;t=i; while(x) { t=num[t]; x--; } re[t]=ch[i]; } for(i=0;i<n;i++) { printf("%c",re[i]); } printf("\n"); } printf("\n"); } return 0;}
0 0
- POJ1026
- poj1026
- poj1026
- poj1026
- poj1026
- poj1026
- poj1026
- poj1026
- poj1026
- poj1026--Cipher
- POJ1026 Cipher
- poj1026 模拟
- POJ1026 HDU1439 Cipher
- POJ1026,Cipher,数学题
- poj1026解题报告
- POJ1026 Cipher 【polya】
- poj1026 Cipher 置换群
- 置换群 POJ1026
- 一般函数指针和类的成员函数指针
- 代理服务器 Squid
- UVA514:Rails(铁轨)
- 九度 oj 题目1090:路径打印
- LVS集群中的IP负载均衡技术
- poj1026
- Caliburn.Micro学习笔记(五)----协同IResult
- [转载]AlphaGo 的棋局,与人工智能有关,与人生无关
- 关键字const的使用总结
- Android系统模块编译
- spring profile的基本使用
- Redis实现Mybatis的二级缓存
- hive中的order by , sort by, distribute by, cluster by
- C++友元详解