uva306 - Cipher 置换群

MEME-CHIP实战:5步搞定ChIP-seq数据中的motif发现与可视化 本文提供了使用MEME-CHIP工具进行ChIP-seq数据motif发现与可视化的完整实战指南。通过5个清晰步骤,从数据准备、环境搭建、命令行执行到结果解读与高级可视化,详细讲解了如何利用MEME-CHIP工作流高效完成从原始peak序列到发表级motif图的分析,并分享了关键的参数调优与避坑经验。 阅读详情

Cipher 

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, tex2html_wrap_inline27 , 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 tex2html_wrap_inline33 , where tex2html_wrap_inline33 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 tex2html_wrap_inline51 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     

  给你一种置换方法,a[i]=j就是经过一次置换,第i个位置的元素到j位置去了。问经过n次置换以后的字符串。

  如果暴力会超时的,但是n只有200。。因为置换是不重复的,所以最多经过n次又换成了他自己。。也就是它有一个周期,周期最大是n。

  比如第一个样例 1-4-7-1。。。2-5-2。。。3-3。。。6-8-6。。。9-10-9。。(147)(25)(3)(68)(9,10)这么循环,所以只要找到每个位置的周期就很快了不会超时。


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<algorithm>
#define INF 0x3f3f3f3f
using namespace std;
int N,M;
char str[210],ans[210],code[210];
int t[210],a[210];
void init(){
    int i,j,p;
    memset(t,0,sizeof(t));
    for(i=1;i<=N;i++){
        p=a[i];
        t[i]=1;
        while(p!=i){
            p=a[p];
            t[i]++;
        }
    }
}
void solve(){
    memset(ans,' ',sizeof(ans));
    int i,j;
    for(i=1;str[i];i++) ans[i]=str[i];
    for(i=1;i<=N;i++){
        int n=M%t[i],p=i;
        for(j=0;j<n;j++) p=a[p];
        code[p]=ans[i];
    }
    for(i=1;i<=N;i++) printf("%c",code[i]);
    puts("");
}
int main(){
    freopen("in.txt","r",stdin);
    while(scanf("%d",&N),N){
        int i;
        for(i=1;i<=N;i++) scanf("%d",&a[i]);
        init();
        while(scanf("%d",&M),M){
            gets(str);
            solve();
        }
        puts("");
    }
    return 0;
}



基于BEV(鸟瞰图)的3D检测:PointPillars与CenterPoint 基于BEV(鸟瞰图)的3D检测:PointPillars与CenterPoint​ ,人工智能,计算机视觉,大模型,AI,本文围绕基于BEV的3D检测,解析了PointPillars与CenterPoint两种算法。PointPillars用点柱特征编码网络处理点云,通过2D卷积网络提取特征,检测头为解耦头;CenterPoint将三维物体表为点,分两阶段检测,先找中心点及属性,再细化预测。两者都可借特定骨干网生成BEV特征图且基于BEV检测,但检测头设计和物体表示方式不同。 阅读详情

相关推荐

排列显示阿拉伯语、数字及英文时的处理方法

这段时间参与开发沙特阿拉伯的网站模板,模板使用的语言是阿拉伯语,其显示顺序为从右到左,而中文、数字及英文的显示顺序为从左到右 ,所以当遇到一行文字内既有阿拉伯语又有数字和英文时会出现语序混乱的问题,如 期待显示的文案为: 按顺序写入,对应的代码如以下,其中currency_pay为变量,值为356SAR <span>الدفع الفعلي:{{currency_pay}}</span> 显示为 الدفع الفعلي : 356SAR 金额356和货币符号SAR分开了,这样显

llq886的博客 5802

【题解】 UVA306 Cipher

题目相当于是求一个串按某种指定方式换位多次后形成的串。 因为 kkk 很大,所以不能直接模拟。 我们考虑样例,对于一个以 4 5 3 7 2 8 1 6 10 9 为标准的转移,我们若转移两次,就相当于进行一次以 7 5 3 1 2 8 4 6 10 为标准的转移,并且每次换的方式是固定的,所以满足结合律,可以用快速幂来解决。 时间复杂度为 O(nlogk)O(nlogk)O(nlogk) #include<bits/stdc++.h> using namespace std; const in

YuZKQ的博客 228

FAST-LIO2实战:如何在无人机上部署并实现厘米级定位(附ROS配置全流程)

本文详细介绍了如何在无人机上部署FAST-LIO2激光雷达惯性里程计系统,以实现厘米级精确定位。内容涵盖从硬件选型(如激光雷达与机载计算机)、软件环境配置(ROS Noetic)、传感器标定,到FAST-LIO2参数调优、与PX4飞控集成以及实际飞行测试的全流程。重点解决了实时定位中的外参标定、数据同步等关键问题,为无人机在无GPS或复杂光照环境下提供稳定可靠的定位解决方案。

weixin_29062865的博客 249

UVA 306 Cipher

UVA_306     一开始倒是想到了这种移位加密是有周期的,但最后却是用的它们的最小公周期去算的。     后来发现比别人的程序要慢很多,仔细看后才发现实际可以对每个字符的位置都用它自己的周期算一下,得到的位置也就是该字符最终的位置,这样相比用最小公周期去算要节省很多时间。 #include&lt;stdio.h&gt;#include&lt;string.h&gt;#define ...

weixin_34192732的博客 143

深入解析经典蓝牙连接:从HCI命令到LMP协议的完整流程

本文深入解析经典蓝牙连接的完整流程,从设备发现、寻呼建立物理链路,到安全配对与加密的每一步。通过对照HCI LOG与AIR LOG,详细拆解了HCI命令与LMP协议报文的对应关系,帮助开发者精准定位连接问题,掌握蓝牙调试的核心方法。

weixin_29260291的博客 449

告别重复劳动:用Python+pywinauto打造你的微信个人助理(自动回复/收款/定时发消息)

本文介绍如何利用Python和pywinauto库构建微信个人助手,实现自动回复、定时消息、智能收款等功能,告别重复劳动。通过详细的代码示例和配置指南,帮助开发者快速掌握微信自动化技术,提升工作效率。

weixin_42568801的博客 328

UVa:306 Cipher

这个题去年就看到了,但是用模拟的办法超时了。如果每次模拟都记录下字符串还会内存超限。后来得知是置换群。每个字符的出现都是有周期的,这样整个串的周期就是所有字符周期的最小公倍数数。如果求了串的周期,k取模之后再模拟,还是会超时。正确的办法是k对每个字符的周期取模,然后对字符操作。 #include #include #include #include #include #inc

Fighting 810

保姆级教程:手把手教你用Jacquard V2数据集训练机器人抓取模型(附完整代码)

本文提供了一份详细的保姆级教程,手把手教你使用Jacquard V2数据集训练机器人抓取模型。从环境配置、数据准备到模型架构设计、训练优化和实际部署,全程解析并附完整代码,帮助开发者快速掌握视觉抓取技术。

weixin_29031057的博客 313

uva 306 - Cipher(周期)

题目链接:uva 306 - Cipher 题目大意:给出n,以及a1 ~ an, 然后给出k,若k不为0的话,会有一个字符串,按照给出的a方式编码k次,输出所得字符串。 解题思路:这题和我刚做的一题有点像,uva 10205 - Stack 'em Up,不过那道题是用模拟的方式,这题刚开始用了模拟,结果超时了,后来想到说,因为a1 ~ an为不等的1~n,所以一定存在一个周

不慌不忙、不急不躁 2354

【实战揭秘】高胜率集合竞价抓涨停策略:融合MACD背离与斐波那契的量化模型

本文揭秘了一种高胜率集合竞价抓涨停策略,融合MACD背离与斐波那契数列的量化模型。通过量能异动、技术形态突破和资金共识形成的交叉验证,该策略在实盘中表现出色。文章详细解析了MACD背离的量化实现细节、斐波那契数列的实战应用,以及策略的量化建模过程,帮助投资者提升交易胜率。

herb5的博客 1554

2026华为OD机试(C++)真题【E卷+A卷+B卷+C卷+D卷】目录+在线OJ

华为OD机试真题题库【E卷+A卷+B卷+C卷+D卷】目录,C++实现。

MISAYAONE的博客 20万+

UVA306 Cipher[循环节]

UVA306 CipherUVA306\ CipherUVA306 Cipher Description\mathcal{Description}Description Bob和Alice开始使用一种全新的编码方案。令人惊讶的是,这不是公共关键字密码系统,他们的编码和解码都是基于一种特殊的密码。他们于1996年2月16日在费城的最后一次会议上确定了他们的密码。他们把密...

Zbr162的博客 250

【人工智能之深度学习】21. 自动驾驶感知实战:YOLOv4复杂天气优化方案(BDD100K全代码+效果对比)

摘要:自动驾驶摄像头在雨雾天气下易受图像模糊、目标遮挡影响,导致YOLOv4检测精度骤降。本文基于BDD100K公开数据集(含多天气场景),设计三阶段优化方案:1)物理建模生成雨雾效果(雨滴线条+大气散射模型),将恶劣天气样本占比从20%提升至40%;2)在YOLOv4颈部嵌入CBAM注意力机制,强化模糊区域特征提取;3)L1剪枝(30%)+TensorRT量化实现轻量化。需特别说明:本文为教学虚拟案例,不可直接用于车载部署,实际落地需结合多传感器融合与ISO 26262认证。

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 1684

UVa 306 / POJ 1026 / Central Europe 1995 Cipher (置换群)

306 - Cipher Time limit: 3.000 seconds  http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=115&page=show_problem&problem=242\ Bob and Alice started to use a brand-new

AC,∑ndless 2641

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

UVa OJ 题解索引

寂静山林 744

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

uva1415 - Gauss Prime 高斯素数

In the late 1700s', Gauss, a famous mathematician, found a special kind ofnumbers. These integers are all in the form: a + b.The sum and multiplicationofthese integers can be naturally defined as the

2138

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

勾股数公式

公式 a=m,b=(m^2 / k - k) / 2,c=(m^2 / k + k) / 2 其中m ≥3 ⒈ 当m确定为任意一个 ≥3的奇数时,k={1,m^2的所有小于m的因子}  (m^2是奇数,k只能是奇数,(m^2 / k - k)是偶数) ⒉ 当m确定为任意一个 ≥4的偶数时,k={m^2 / 2的所有小于m的偶数因子} (若k是奇数,m^2/k是偶数,加上k是奇数,

2015

uva106 - Fermat vs. Pythagoras 互素勾股数

Fermat vs. Pythagoras  Background Computer generated and assisted proofs and verification occupy a small niche in the realm of Computer Science. The first proof of the four-color probl

2011

uva11889 - Benefit 数论

Benefit  Recently Yaghoub is playing a new trick to sell some more. When somebody gives him A Tomans, hewho never has appropriate changes, asks for B Tomans such that lowest common multip

1356

快速打素数表

int prime[MAXM]; bool vis[MAXN>>1]; void prime_table(){ memset(vis,0,sizeof(vis)); int sq=sqrt(MAXN+1); //+1防止误差 prime[0]=2; num=1; for(int i=3;i<=sq;i+=2){ if(vis[i>>1]

1071

uva10601 - Cubes 正方体置换

Problem B Cubes   You are given 12 rods of equal length. Each of them is coloredin certain color. Your task is to determine in how many different ways one canconstruct a cube using these rods a

1066

高斯消元在开关灯泡问题中的应用

为了这个又去翻线代书。。。

1001

uva557 - Burger 概率递推

Burger  When Mr. and Mrs. Clinton's twin sons Ben and Bill had their tenth birthday, the party was held at the McDonald's restaurant at South Broadway 202, New York. There were 20 kids at

994

uva10673 - Play with Floor and Ceil 扩展欧几里德算法

Problem A Play with Floor and Ceil Input: standard input Output: standard output Time Limit: 1 second   Theorem For any two integers x and k there exists two more integers p and q such that:

928

uva11181 - Probability|Given 条件概率

Problem G Probability|Given Input: Standard Input Output: Standard Output   N friends go to the local super market together. The probability of their buying something from the market is respecti

922

uva11029 - Leading and Trailing n^k保留前三位

Problem C Leading and Trailing Time limit: 2 seconds   Apart from the novice programmers, all others know that you can’t exactly represent numbers raised to some high power.

883
上一篇: uva10994 - Simple Addition
下一篇: uva658 - It's not a Bug, it's a Feature! 状态压缩+隐式图搜索+优先队列的dijkstra
小小小小葱
博客等级 码龄14年 22粉丝 266原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值