uva306 - Cipher 置换群

STM32CubeMX——循迹传感器TCRT5000的使用 前言 人生如逆旅,我亦是行人。 ————苏轼《临江仙·送钱穆父》 一、介绍 TCRT5000描述:(带有晶体管输出的反射光学传感器) TCRT5000是一种反射式光学传感器,它包括一个红外发射器和一个3.5mm引线封装的光电晶体管,可阻挡可见光。还具有1mA 典型被测输出电流,2.5mm峰值工作距离,可应用传感与仪表,工业等行业。 TCRT5000具有紧凑的结构,其中发射光源和探测器布置在同一方向,通过使用来自物体的反射红外光束来感知物体的存在。工作波长为950毫米,探测器由光电晶体管组成 阅读详情

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;
}



用一张分析型 CDS Query 看清争议案件新增与结案节奏:C_OpenClosedDisputeCase 深度解读 应收账款争议管理中的关键CDS视图分析 摘要:C_OpenClosedDisputeCase是SAP系统中用于监控应收账款争议案件的重要CDS视图,提供三个时间窗口(当日、近5天、当月)的新增与结案数据。该视图通过"创建vs解决"的净变化指标,帮助财务团队实时掌握争议管理趋势,特别适用于多币种跨国企业的现金流管理。其核心价值在于将争议管理从被动"救火"转变为可量化运营,通过统一汇率换算和关键日期参数,为管理层提供标准化的运营仪表盘。视图采用特权访问模式,需通过上层应用 阅读详情

相关推荐

行政数据分析大屏实战:用Tableau从Excel到看板的完整搭建流程(含数据连接与字段计算避坑)

本文详细介绍了如何利用Tableau从Excel数据源搭建行政数据分析大屏的完整流程,涵盖数据准备、连接技巧、计算字段优化、看板设计及动态交互部署。通过五阶工作流,帮助用户高效处理多源异构数据,实现业务洞察与可视化呈现,提升行政数据分析效率。

weixin_29696711的博客 351

UVa:306 Cipher

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

Fighting 810

【AIGC】人工智能训练师(高级)考试题库-橙点同学

例如,在嘈杂的环境中进行声音转文字,即使是优秀的模型也可能会出现一些错误,但这并不意味着该模型本身质量差,在其他较为理想的环境下,它可能会有很好的表现。例如,在一些语音应用和系统中,会使用SSML来实现对语音合成的精细控制,如调整语速、语调、音量等,而这些应用和系统的开发往往会遵循W3C的相关标准和框架,其中就包括SSML这一语音合成标记语言。例如,在语音识别等场景中,像“去火车站怎么走”这样的语音指令,没有其他嘈杂的背景声音或模糊不清的表述,就属于无噪音的数据,有利于系统准确地进行处理和分析。

RisunJan的博客 9972

UVA306 Cipher[循环节]

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

Zbr162的博客 251

Ubuntu更新后VirtualBox报错rc=-1908?手把手教你修复Kernel driver not installed

本文详细解析了Ubuntu更新后VirtualBox报错rc=-1908的原因,并提供了完整的修复方案。通过重新安装VirtualBox、处理DKMS内核模块以及解决Secure Boot问题,帮助用户快速恢复虚拟机功能。特别针对Kernel driver not installed错误,给出了从诊断到修复的详细步骤。

weixin_42519781的博客 349

MRI脑影像分析从哲学到技术:一文搞懂VBM预处理基本原理(全网最详细解析)

   分析大脑解剖学差异最常用方法之一是基于体素的形态学方法(voxel-based morphometry, VBM)。 VBM的基本思想是测量大脑组织,尤其是灰质的局部浓度的差异。在大脑的每个体素处进行操作,然后在两个或多个实验组之间进行统计比较,从而在受调查的组之间建立特定大脑区域中脑组织浓度的统计学显着差异。 VBM分析基于(高分辨率)MRI脑部扫描,涉及大量处理步骤,主要是空间归一化,分割,平滑和统计分析,最终结果是统计图,显示了各组之间组织类型明显不同的区域[^1]。 参考 [^1] ..

意疏的学习笔记 3万+

【题解】 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的博客 230

【MATLAB】嵌入式PID控制参数整定与优化

本文提出了一种基于MATLAB仿真的嵌入式PID参数优化方法,解决了传统人工试凑法效率低、适应性差的问题。通过建立一阶滞后被控对象模型,对比分析了不同PID参数组合的性能表现,筛选出最优参数。仿真结果表明,优化后的PID参数能有效降低超调量(从传统方法的显著超调降至接近0%),缩短调节时间,提高稳态精度。最终将优化算法部署到STM32平台,实现了"仿真整定-参数优化-嵌入式落地"的完整开发流程。该方法显著提升了嵌入式系统的响应速度和控制精度,为工业控制应用提供了标准化解决方案。

unber的博客 57

UVA 306 Cipher

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

weixin_34192732的博客 144

halcon3d点云补全方法

属于halcon实例中的内容,后面还接了一部分的匹配

Tianwen_running的博客 1237

前拉后推计划逻辑适用于哪些行业和企业规模?

《前拉后推计划逻辑的行业适用性分析》摘要:前拉后推计划逻辑(需求端后推锚定交付、供应端前拉匹配资源)最适用于需求波动大且具规模效益的行业,包括家具制造(定制化需求+批量运输)、机械装备(非标设备+部件采购)、消费电子(短周期产品+核心部件备货)及汽车配套(交期绑定+批量生产)等领域。该模式要求企业具备:1)独立计划部门;2)ERP/MES等信息系统;3)资源冗余能力,故更适配中型(1-10亿营收)和大型企业(10亿+)。小型企业需简化应用,仅聚焦关键环节。不适配需求稳定(如快消品)、无规模效益或短周期生产的

追随内心 153

uva 306 - Cipher(周期)

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

不慌不忙、不急不躁 2357

2. SDK分析

由恒玄提供,版本《best1603_ibrt_anc_20240124_207ba3fb90.tar》恒玄bes2700 sdk属于恒玄面向耳机市场的sdk,主要参考。

雪飞_海 2777

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 2643

inori mmd 7z

楪祈的模型资源....................................................................................................................................................................................................................

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

UVa OJ 题解索引

寂静山林 795

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

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

2143

IDEA的使用指南

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

勾股数公式

公式 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是奇数,

2016

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

2013

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

1358

快速打素数表

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]

1075

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

1067

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

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

1003

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

998

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:

929

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

924

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.

886
上一篇: 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、付费专栏及课程。

余额充值
⌂ 换网址