uva306 - Cipher 置换群

ISCE+Mintpy进行SBASInSAR处理(持续更新) 通过调用pairs_misregistration方法,利用safe_dict中的数据信息,对每对SLC数据进行配准误差的计算和分析,以确定数据之间的精确差异,为后续的时间序列处理提供基础。给定同一地区的两景SAR影像,经过配准之后,对应像元进行共轭相乘得到相位差,并形成干涉图,但是从干涉图中得到的相位差实际上是主值,即在(-π,π)呈周期性变化,为了还原其真实的相位差,必须在主值的基础上加或减整数倍的相位周期2π,把被卷叠的相位展开,才能顺利地反演出地面目标的高程和形变。 阅读详情

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



深入解析ffmpeg编码错误:avcodec_send_frame()返回-22的排查与修复 本文深入解析FFmpeg编码中avcodec_send_frame()返回-22(AVERROR(EINVAL))错误的根本原因与系统排查方法。核心问题通常在于编码器未正确打开或上下文传递错误。文章提供了从检查编码器查找、确认avcodec_open2()调用,到验证上下文传递的完整修复指南,并附有可运行的代码示例,帮助开发者快速定位并解决这一常见编码障碍。 阅读详情

相关推荐

RandLA-Net复现SemanticKITTI和S3DIS数据集

RandLA-Net复现KITTI和室内数据集

weixin_48845174的博客 4129

UVA306 Cipher[循环节]

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

Zbr162的博客 250

Claude skill-creator插件深度解析:从创建到优化的完整技能工程化体系

摘要:skill-creator是Anthropic推出的Claude技能开发插件,提供从创建到优化的全流程工程化支持。其核心架构采用渐进式披露机制和多Agent协作模式,包含Grader、Analyzer等专业评估组件。该插件支持自动化评测系统,通过测试用例管理、并行执行和结果聚合实现技能验证;提供迭代优化算法,基于数据驱动改进技能性能。典型应用场景包括标准化技能开发、自动化测试验证和触发优化,显著降低开发门槛并提升技能质量。

虚心若愚 998

uva 306 - Cipher(周期)

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

不慌不忙、不急不躁 2354

pagerank算法详解

目录一、pagerank定义两个重要假设二、pagerank算法公式定义计算演示矩阵化计算三、存在的两个问题问题1.Dead Ends问题2.Spider Traps 一、pagerank定义 入链数:指向该节点的链接数 出链数:由该节点指出的链接数 以上图为例:A的入链数为1,出链数为3,所以将由A指向其他节点的边权重设置为1/3,表示A访问B、C、D节点的概率均为1/3 两个重要假设 数量假设:在Web图模型中,如果一个页面节点接收到的其他网页指向的入链数量越多,那么这个页面越重要。 质量假设:指向

gary101818的博客 4万+

R语言分段回归

1.利用虚拟变量进行线性回归 (MEdata.csv的数据来源:https://github.com/ChenQihome9/CSDN-Data-Library/blob/master/MEdata.csv) 问题13:针对TAX~GDP,使用分段回归方法,找到其回归方程。编程,并根据程序结果叙述如下几方面问题:(1)分几段最佳?(不超过5段内)(2)分段位置定在哪儿最佳?(3)写出最佳方...

ChenQihome9的博客 1万+

UVa:306 Cipher

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

Fighting 810

AI 生成 ECU 功能测试用例

本文分享了AI辅助汽车电子测试的实战经验。作者以某车企车身控制器(BCM)项目为例,对比了传统测试用例编写方式(需100小时)与AI辅助方式(仅3个工作日)的效率差异,实现76%的效率提升。文章详细展示了从需求文档生成测试用例的全过程,包括需求文档示例、AI提示词模板和AI生成的完整测试用例表格(涵盖正常功能、边界条件、异常场景等测试类型)。通过具体案例说明如何利用AI快速生成初稿后人工审核优化的方法,为ECU测试工程师提供了可复用的效率提升方案。

小明的博客 920

UVA 306 Cipher

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

weixin_34192732的博客 144

MNI152 坐标空间和 fsaverage 坐标空间相互转换, 如已知fsaverage空间的坐标如何求MNI152 坐标?aparc.a2009s.annot转化到MNI152空间?

大多数神经影像学研究的结果是在体积(例如,MNI152)或表面(例如,fsaverage)坐标系中报告的。体积坐标系和表面坐标系之间的准确映射可以促进许多应用,例如将 fMRI 组分析从 MNI152 投影到 fsaverage 以进行可视化或从 fsaverage 投影静息状态 fMRI 分区对 MNI152进行新数据的体积分析。Wu et al., 2018 评估了三种在 MNI152通过模拟上述应用的 Colin27 和 fsaverage 坐标系:将组平均数据从 MNI152/Colin27 投影到

从事脑科学核磁共振方法学研究,在Nature communications等权威期刊发表研究论文,熟练掌握磁共振处理方法和统计学方法,欢迎大家和我交流。 2975

openbmc 支持mctp over pcie(二)

本文介绍了在OpenBMC系统中实现MCTP over PCIe的社区方案,主要针对AMD CPU和Intel CPU平台。方案基于社区开发的mctpd应用层和内核驱动,通过修改设备树(dts)配置内存区域,并编译Linux内核模块。验证时可通过查看/proc/net/protocols确认MCTP协议支持,使用ip addr命令检查mctppci0网络接口状态。相关代码和文档参考了AspeedTech和CodeConstruct的GitHub仓库。该方案为BMC作为MCTP端点提供了标准化实现方法。

wit_yuan的专栏 386

【题解】 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

【Bug已解决】Codex CLI 报错 apply_patch 失败:无法应用补丁的解决方案

方案适用场景推荐指数统一换行符规范跨平台协作项目的标准配置⭐⭐⭐⭐⭐关闭自动格式化冲突IDE 与 Codex 并发编辑同一文件⭐⭐⭐⭐缩小任务改动范围长期有效的使用习惯优化⭐⭐⭐⭐⭐统一 UTF-8 编码涉及非 UTF-8 遗留文件的项目⭐⭐⭐提示重新读取文件单次失败后的快速恢复方式⭐⭐⭐⭐报错的本质是Codex 生成补丁时读取的文件内容,与实际应用补丁时磁盘上的文件内容出现了不一致,常见诱因包括换行符风格混用、文件被其他工具并发修改、编码问题等。

一键难忘的博客 7334

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

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

UVa OJ 题解索引

寂静山林 790

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

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

2142

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

勾股数公式

公式 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

2012

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

1357

快速打素数表

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]

1073

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

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

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

1002

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

995

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

923

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.

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

余额充值