uva12103 - Leonardo's Notebook 置换A^2=B

UMD与KMD的协同交响曲:揭秘图形渲染背后的驱动架构设计 本文深入解析了图形渲染中用户态驱动(UMD)与内核态驱动(KMD)的协同架构设计,揭秘了从API调用到像素渲染的完整流水线。通过分析UMD的API转换、着色器编译等核心职责,以及KMD的内存管理、任务调度等关键功能,帮助开发者优化图形应用性能,提升渲染效率。 阅读详情

I just bought Leonardo's secret notebook! Rare object

collector Stan Ucker was really agitated but his friend,
special investigator Sarah Keptic was unimpressed.
| How do you know it is genuine?
| Oh, it must be, at that price. And it is written in
the da Vinci code. Sarah browsed a few of the pages. It
was obvious to her that the code was a substitution cipher,
where each letter of the alphabet had been substituted by
another letter.
| Leonardo would have written the plain-text and left
it to his assistant to encrypt, she said. And he must have
supplied the substitution alphabet to be used. If we are
lucky, we can nd it on the back cover!
She turned up the last page and, lo and behold, there
was a single line of all 26 letters of the alphabet:
QWERTYUIOPASDFGHJKLZXCVBNM
| This may be Leonardo's instructions meaning that each A in the plain-text was to be replaced
by Q, each B with W, etcetera. Let us see
:::
To their disappointment, they soon saw that this could not be the substitution that was used in the
book. Suddenly, Stan brightened.
| Maybe Leonardo really wrote the substitution alphabet on the last page, and by mistake his
assistant coded that line as he had coded the rest of the book. So the line we have here is the result of
applying some permutation TWICE to the ordinary alphabet!
Sarah took out her laptop computer and coded ercely for a few minutes. Then she turned to Stan
with a sympathetic expression.
| No, that couldn't be it. I am afraid that you have been duped again, my friend. In all probability,
the book is a fake.
Write a program that takes a permutation of the English alphabet as input and decides if it may
be the result of performing some permutation twice.
Input
The input begins with a positive number on a line of its own telling the number of test cases (at most
500). Then for each test case there is one line containing a permutation of the 26 capital letters of the
English alphabet.
Output
For each test case, output one line containing `
Yes
' if the given permutation can result from applying
some permutation twice on the original alphabet string ABC
:::
XYZ, otherwise output `
No
'.
SampleInput
2
QWERTYUIOPASDFGHJKLZXCVBNM
ABCDEFGHIJKLMNOPQRSTUVWXYZ
SampleOutput
No
Yes

  长度为n的循环节,如果n是奇数,那么一定能找到一个长度为n的A,使A^2=B。对于任意两个长度为n的的不相交循环B,C,都能找到一个长度为2n的循环A,A^2=BC。

  比如(a1a2a3)(a1a2a3)=(a1a3a2),(b1b2b3b4)(b1b2b3b4)=(b1b3)(b4)。

  所以这里可以找出所有循环节的长度,只要长度为奇数的不是奇数个都可以。

#include<iostream>
#include<algorithm>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#define INF 0x3f3f3f3f
#define MAXN 2000010
#define MAXM 1500
#define MOD 1000000007
#define MAXNODE 8*MAXN
#define eps 1e-9
using namespace std;
typedef long long LL;
int T,vis[MAXN],cnt[MAXN];
char B[MAXN];
int main(){
    freopen("in.txt","r",stdin);
    scanf("%d",&T);
    while(T--){
        scanf("%s",B);
        memset(vis,0,sizeof(vis));
        memset(cnt,0,sizeof(cnt));
        for(int i=0;i<26;i++) if(!vis[i]){
            int j=i,n=0;
            do{
                vis[j]=1;
                j=B[j]-'A';
                n++;
            }while(j!=i);
            cnt[n]++;
        }
        int flag=1;
        for(int i=2;i<=26;i+=2) if(cnt[i]%2){
            flag=0;
            break;
        }
        if(flag) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}



MT4/MT5 第三代移动平均线(MetaTrader 指标) 第三代移动平均线(3G-MA)是传统MA指标的升级版本,通过"时滞压缩"算法将信号滞后降至理论极限(λ=2)。该指标在保留平滑性的同时,信号速度比EMA快1.5-2.3倍,适用于MT4/MT5平台。核心参数包括计算周期(默认34)、滞后压缩系数(2-10)和应用价位选择,支持斜率变色功能。安装简单,无需外部依赖,通过多周期共振可提升12-18%胜率。指标代码包含完整的MT4/MT5实现方案,采用双缓冲计算结构,通过相位前移算法抵消群延迟。风险提示:需配合其他技术指标和严格风控(≤2%账户 阅读详情

相关推荐

吃透 AM32 无人机电调:从源码架构到工作原理的全方位解析(附实践指南)(中)

介绍了三相电机控制中的SVPWM算法实现及保护机制设计。SVPWM部分详细解析了电压矢量扇区判断、占空比计算和过调制保护,通过限制占空比范围(0-100%)防止电机失控,并提供了完整的代码实现。保护模块则重点分析了过流、过压/欠压、过温三种保护机制,采用分级处理策略(硬保护停机/软保护降功率)确保系统安全。此外,文章还介绍了参数管理模块在STM32 Flash中的存储方案,包括参数定义、数据结构和读写操作,为电机控制系统提供了完整的解决方案。

bother3000的博客 1391

uva 12103 - Leonardo's Notebook(置换)

题目链接:uva 12103 - Leonardo's Notebook 题目大意:给出26个字母的置换,问是否存在一个置换A,使得A2=B 解题思路:将给定置换分解成若干个不相干的循环,当循环的长度n为奇数时,可以由两个循环长度为n的循环的乘积得来,也可以由两个循环长度为2n的拆分而来;对于长度n为偶数的,只能由两个循环长度为2n的拆分而来,所以判断是否存在有循环长度为偶数的个数是奇

不慌不忙、不急不躁 1288

WPS和Excel通用!省市区四级联动下拉菜单保姆级教程(附最新行政区划数据包)

本文详细介绍了在WPS和Excel中实现省市区四级联动下拉菜单的完整教程,包含2024年最新行政区划数据的获取与整理方法。通过名称管理器和INDIRECT函数的组合,以及WPS的特色功能,帮助用户高效准确地录入四级行政区划信息,提升数据录入效率并减少错误。

s1t2u3的博客 624

UVA - 12103 Leonardo's Notebook

置换、图论、构造

ACoder 230

C# 实战:利用aspnet_regiis加密App.config与Web.config中的敏感数据

本文详细介绍了如何使用C#官方工具aspnet_regiis加密App.config与Web.config中的敏感数据,如数据库连接字符串和API密钥。通过实战步骤演示了如何加密appSettings和connectionStrings节点,确保配置安全的同时,代码无需任何修改即可自动解密。文章还涵盖了桌面程序处理、配置更新解密以及跨机器部署的进阶RSA方法,为C#开发者提供了一套完整的配置文件安全解决方案。

weixin_29266647的博客 156

【网络】PFC背景和原理 、文档(DCB=PFC + ETS,DCBX=DCB扩展)

目录 零、背景 一、PFC 1.概述 2.报文格式 3.工作机制 二、ETS 产生原因 基本原理 优先级组的调度 优先级的调度 三、DCBX 产生原因 基本原理 DCBX TLV介绍 五、PFC 拥塞研究(文档收集) 六、DC-QCN算法 (网络工程师必会) 7.1 α更新 7.2 降速 7.3 提速 8.总结 ...

小鱼菜鸟的博客 2168

题解 UVA12103 Leonardo's Notebook

题解 UVA12103 Leonardo’s Notebook Date 2019.8.1 题目大意 给出26个大写字母的置换B,问是否存在一个置换A,使得A2=B。 思路 我们可以在置换B中找出所有的环 举个例子:假设现在置换B为"BAC",它就包含着两个环——一个以A、B组成的环,和一个由C组成的自环。 我们将环分为两类:奇环和偶环。A、B组成的环就是偶环,而C的自环就是奇环。如果有某个长度...

Lificious的博客 223

vos如何对接okcc(保姆级教程)

1.添加账户 点击 系统->账户管理 [图片] 2.创建费率 系统->费率管理 点击添加

qq_46333281的博客 3458

UVA12103 —— Leonardo's Notebook —— 置换分解

题目链接:https://vjudge.net/problem/UVA-12103 题意: 给出大写字母“ABCD……Z”的一个置换B,问是否存在一个置换A,使得A^2 = B。 题解: 对于置换,有以下结论: 其中“结论三”是一般性结论。 因此: 1.对于长度为len的循环T,则T^2为gcd(len,2)个循环。即:当len为偶数时,T^2...

alince20008的博客 174

别再对着数据手册画图了!用HFSS 2023 R2快速复现ESP-01的PCB天线(附模型文件)

本文详细介绍了使用HFSS 2023 R2逆向复现ESP-01 PCB天线的五个关键步骤,包括逆向工程准备、高效建模技巧、材料与边界设置、激励与求解配置以及结果分析与设计验证。通过参数化建模和智能边界检测,大幅提升仿真效率,适用于WIFI和蓝牙设备的射频设计优化。

weixin_30832143的博客 81

An example: 2D immersed boundary lattice Boltzmann method code--By Timm Krüger.2011.

//谢谢Timm Krüger大佬的代码。 还是老样子,有啥问题Feel free to tell us~毕竟群众力量大嘛~QQ群:293267908。 // 话不多说,上干货! // ISBN 978-3-319-44649-3 (Electronic) // 978-3-319-44647-9 (Print) // http://www.springer.c...

weixin_37783345的博客 1423

UVA 12103 - Leonardo's Notebook(数论置换群)

UVA 12103 - Leonardo's Notebook 题目链接 题意:给定一个字母置换B,求是否存在A使得A^2=B 思路:任意一个长为 L 的置换的k次幂,会把自己分裂成gcd(L,k) 分, 并且每一份的长度都为 L / gcd(l,k),因此平方对于奇数长度不变,偶数则会分裂成两份长度相同的循环,因此如果B中偶数长度的循环个数不为偶数必然不存在A了 代码:

Remilia's 1897

【网络安全】SSRF漏洞讲解

SSRF漏洞讲解一、初识SSRF漏洞1.定义2.产生原理3.会导致的危害4.常见产生SSRF的地方5.常见缺失函数二、SSRF漏洞利用1.函数(1) file_get_contents(2)fsockopen()(3) curl_exec()2.协议(1)file协议(2)http协议(3)dict协议(4)gopher协议三、绕过1.绕过方式(1)检查IP是否为内网IP(2)Host获取与DNS绕过(3)通过各种协议(4)利用URL解析器滥用问题四、修复修复方案五、小结 一、初识SSRF漏洞 1.定义

你在看屏幕的同时,屏幕也在注视着你 3189

UVA - 12103 Leonardo's Notebook (置换乘法的应用)

传送门:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3255 题解:LRJ训练之南p147 说一下碎玉置换A=(a1 a2 a3)(b1 b2 b3 b4)的平方怎么得出来的: (a1 a2 a3)(a1 a2 a3)=>a1->a2->a3,a

Vision 434

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

UVA 12103/poj 3128/hdu 1975/UVALive 3641 Leonardo's Notebook 置换

#include #include using namespace std; int c[30],vis[30]; char a[30]; int main() { int T; cin>>T; while(T--) { int i,j,k,t,flag=0; cin>>a; memset(c,0,sizeof(c

冷月之殇 1233

visio安装包

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

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

老版QQ原生表情gif动态

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

勾股数公式

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

uva306 - Cipher 置换群

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

1219

快速打素数表

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

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

996

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
上一篇: hdu4923 Room and Moor 单调栈
下一篇: uva10601 - Cubes 正方体置换
小小小小葱
博客等级 码龄14年 22粉丝 266原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值