hdoj 1015 Safecracker

从零开始:Basler相机与pylon Viewer的工业视觉入门指南 本文详细介绍了Basler相机与pylon Viewer在工业视觉系统中的入门指南,涵盖硬件连接、软件安装、核心功能解析及实战案例。通过pylon Viewer的全面控制和参数调整功能,帮助新手快速掌握工业视觉检测技术,提升生产效率。 阅读详情

Safecracker

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 8952    Accepted Submission(s): 4533


Problem Description
=== Op tech briefing, 2002/11/02 06:42 CST ===
"The item is locked in a Klein safe behind a painting in the second-floor library. Klein safes are extremely rare; most of them, along with Klein and his factory, were destroyed in World War II. Fortunately old Brumbaugh from research knew Klein's secrets and wrote them down before he died. A Klein safe has two distinguishing features: a combination lock that uses letters instead of numbers, and an engraved quotation on the door. A Klein quotation always contains between five and twelve distinct uppercase letters, usually at the beginning of sentences, and mentions one or more numbers. Five of the uppercase letters form the combination that opens the safe. By combining the digits from all the numbers in the appropriate way you get a numeric target. (The details of constructing the target number are classified.) To find the combination you must select five letters v, w, x, y, and z that satisfy the following equation, where each letter is replaced by its ordinal position in the alphabet (A=1, B=2, ..., Z=26). The combination is then vwxyz. If there is more than one solution then the combination is the one that is lexicographically greatest, i.e., the one that would appear last in a dictionary."

v - w^2 + x^3 - y^4 + z^5 = target

"For example, given target 1 and letter set ABCDEFGHIJKL, one possible solution is FIECB, since 6 - 9^2 + 5^3 - 3^4 + 2^5 = 1. There are actually several solutions in this case, and the combination turns out to be LKEBA. Klein thought it was safe to encode the combination within the engraving, because it could take months of effort to try all the possibilities even if you knew the secret. But of course computers didn't exist then."

=== Op tech directive, computer division, 2002/11/02 12:30 CST ===

"Develop a program to find Klein combinations in preparation for field deployment. Use standard test methodology as per departmental regulations. Input consists of one or more lines containing a positive integer target less than twelve million, a space, then at least five and at most twelve distinct uppercase letters. The last line will contain a target of zero and the letters END; this signals the end of the input. For each line output the Klein combination, break ties with lexicographic order, or 'no solution' if there is no correct combination. Use the exact format shown below."
 


Sample Input
1 ABCDEFGHIJKL 11700519 ZAYEXIWOVU 3072997 SOUGHT 1234567 THEQUICKFROG 0 END
 


Sample Output
LKEBA YOXUZ GHOST no solution
 题目大意:给出一个数字tangt和一个字符串,长度不少于5不超过12,字符串中由大写字母组成,A~Z依次代表1~26,然后在给定的字符串中找5个不同的字符,使对应的数字满足v-w*w+x*x*x-y*y*y*y+z*z*z*z*z=tangt,如果有多组满足的,输出按字典序排大的在先的对应的五个字母,如果没有满足要求的就输出no solution。
因为字符串最长是12,所以时间复杂度大约是O(12*12*12*12*12),也就是O(2.48832*10^5),不大,所以用5层for循环。当然,输入字符串后要对字符串按字典序从大到小排,这要就能保证只要找到满足的等式,就是满足题意的。


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define ret(v,w,x,y,z) (v-w*w+x*x*x-y*y*y*y+z*z*z*z*z)
int tangt,n;
char s[100];
bool judge;
int cmp(const void *a,const void *b)
{
    return *(char *)b-*(char *)a;
}
int main()
{
    int i,j,k,o,p;
    while(scanf("%d %s",&tangt,s)&&(tangt!=0||strcmp(s,"END")!=0))
    {
           n=strlen(s);         
           qsort(s,n,sizeof(s[0]),cmp);
           for(i=0,judge=false;i<n;i++)
           {
                 for(j=0;j<n;j++)
                 {
                      if(j==i) continue;
                      for(k=0;k<n;k++)
                      {
                           if(k==i||k==j) continue;
                           for(o=0;o<n;o++)
                           {
                                  if(o==i||o==j||o==k) continue;
                                  for(p=0;p<n;p++)
                                  {
                                         if(p==i||p==j||p==k||p==o) continue;
                                         else if(ret((s[i]-64),(s[j]-64),(s[k]-64),(s[o]-64),(s[p]-64))==tangt)
                                         {
                                              judge=true;
                                              break;
                                         }         
                                       
                                  }  
                                  if(judge) break;       
                           }                      
                           if(judge) break;         
                      }
                      if(judge) break;
                 }
                 if(judge) break;
           }             
           if(judge)
           printf("%c%c%c%c%c\n",s[i],s[j],s[k],s[o],s[p]);
           else
           printf("no solution\n");
    }
    return 0;
}
                


【DNN实现二分类模型推理部署(C#)----20240712】 阅读详情

相关推荐

自适应陷波器的原理与实现

x(t)是叠加有两个频率干扰信号的输入信号,s(t)是需要保留的有用信号,在输入信号中,我们只知道频率w1和w2,但不知道信号的幅度A和相位θ,自适应陷波器可以估计两个未知的幅度和相位值,这需要我们提供两路相互正交的单频信号,如cos(w1t)、sin(w1t),通过调整其权值,从而合成出与干扰信号完全相同的信号A1cos(w1t+θ1),从而实现干扰信号的滤除。采用LMS算法,在保证不损失其他有用信号的情况下,有效地抑制输入信号中某一频率的干扰,如需滤除多个频率,只需要增加相应的输入信号。

Melkiades2333的博客 6912

hdoj1015

Safecracker Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description === Op tech briefing, 2002/11/02 06:42 CST ===  "The item is locked in a

◆◇丶生如夏花。谁来订阅我的悲伤 564

安卓模拟器绕过检测全解析:雷电、MuMu、蓝叠、逍遥、夜神与WSA完整指南

随着手机游戏和应用的普及,越来越多的用户选择在PC上通过模拟器来运行安卓应用。然而,许多应用和游戏为了防止作弊或出于安全考虑,会检测是否运行在模拟器环境中。本文将详细介绍各大主流模拟器的检测绕过方法,帮助用户在电脑上流畅体验各类安卓应用。1. 获取模拟器系统镜像2. 使用ROM厨房工具修改系统文件3. 替换模拟器的系统镜像雷电模拟器:适合游戏,推荐使用MAGISK + EdXposed方案MuMu模拟器:适合中度游戏,推荐太极框架蓝叠模拟器:适合国际应用,推荐MAGISK方案逍遥模拟器。

专注技术分享 4万+

Ubuntu 20.04 Nginx 安装与生产级配置全指南

Nginx 是高性能 Web 服务器与反向代理的核心基础设施,其运行依赖操作系统内核、网络栈、权限模型及服务管理机制的深度协同。在 Ubuntu 20.04 这一长期支持版本中,apt 源策略、ufw 防火墙默认拦截、systemd 单元加载逻辑、worker 进程资源限制等底层细节,共同决定了 Nginx 能否稳定提供 HTTP/HTTPS 服务。掌握 nginx 反向代理配置原理、nginx 配置文件详解方法,并结合 ufw 端口规则管理、日志轮转与实时诊断能力,是构建高可用 Web 服务链路的技术基础

weixin_34133829的博客 438

Light Tools 8.4 在 win10系统上的安装方法(64位)

** 总的来说安装LT需要以下步骤(折腾了三天终于装好): 安装LT软件–禁用签名–加载含数字签名的第三方inf–添加注册表/安装驱动/添加密钥–成功破解 一、下载对应的LightTools 8.4版本软件,如下图为解压后的文件: 并选择 进行默认安装。 二、禁用数字签名。这里我用了两种方法,一种不行就换另一种,最终成功禁用。 方法1: 1、输入“cmd”并以管理员身份运行; 2、输入或复制 bcdedit.exe /set nointegritychecks on (此命令若没成功,再试bcded

weixin_45560953的博客 1万+

IMU预积分【SLAM】

预积分的推导过程比较多,所以这里只记录关键结论。 其实这些公式不太好记忆,因为预积分推导过程的想法来源很巧妙,无法看出物理意义。一切推导的来源: 最好记忆的旋转相对运动量: △Rij≐RiTRj=∏k=ij−1Exp((ω~k−bg,k−ηgd,k)△t)\triangle R_{ij} \doteq R_{i}^{T}R_{j} = \prod_{k=i}^{j-1}Exp((\tilde{\omega}_{k}-b_{g,k}-\eta_{gd,k})\triangle t) △Rij​≐RiT​Rj​

Tong_1024_的博客 1380

hdoj1015(暴力破解方程式)

题意大致是在1到26整数之中找到不重复的五个整数满足一个等式。 暴力破解!#include #include #include #include #include using namespace std; int main() { char str[30]; char outstr[6]; long t,v,w,x,y,z,i,flag; long r[26]; while(cin>

CqZtw的博客 617

uniapp - H5网页uni.getLocation报错getLocation:fail Geolocation permission denied.Get ipLocation failed.

uni.getLocation getLocation:fail Geolocation permission denied.Get ipLocation failed.,uni.getLocation定位失败,uni-app getLocation()无法获取定位,一直fail()uniapp移动端h5网页,uniApp微信内置浏览器定位失败,如何解决这个问题,uniapp h5 uni.getLocation获取位置失败怎么办,UNI-APP获取当前位置,uni.getLocation定位失败,unia

🏆 前端领域优质创作者 4252

HDOJ-1015(Safecracker)(多重for循环)

HDOJ-1015(Safecracker)(搜索dfs或多重for循环) Safecracker Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10968    Accepted Submission(s): 5632

hpulw 618

CodeX 登录报错 os error 10013?一键修复 CodeX 无法登录问题(亲测有效)

CodeX 登录时报 os error 10013?本文提供快速修复方案,实测有效,彻底解决登录报错:登录失败:failed to start login server: 以一种访问权限不允许的方式做了一个访问套接字的尝试。 (os error 10013)的问题💡

XiaoqiangClub的博客 2968

10倍开发者的 Dify 魔法书:从零构建全栈 AI 应用

“不懂底层算法,也能开发爆款 AI 应用吗?” 答案是:绝对可以。 Dify 正在重新定义 AI 应用的开发范式——通过可视化的低代码平台,将原本需要数周的开发周期压缩到几小时。无论你是前端、后端、产品经理,还是渴望破局的独立开发者,这都是你不可错过的红利。 我们将手把手教你利用 Dify 快速接入百模大战,零代码搭建企业级知识库,并一键发布你的专属 AI 助手、智能客服和自动化工作流。 告别重复造轮子,掌握 Dify,一个人就是一支 AI 团队。现在上车,开启你的 10 倍速开发之旅!

davidwang456的专栏 741

DFS --HDOJ1015 Safecracker

DFS –HDOJ1015 Safecracker 深搜最佳值

Lemhold的博客 538

2、TrustZone(内含链接)——长期学习内容

ARM系列学习路径整理,希望对大家有用。

HoneyIC的博客 242

HDOJ1015 Safecracker

练习点:DFS Tips: 1. cout,cin以及iostream的大量使用会严重降低速度,导致Time Limit Exceeded,以及极大的output size消耗。尽量使用stdio中的。 2. getchar()命令读取单个字符  3. cin.getline(lett_set, 13,'\n');//注意是13最多能读取12个字符长度的字符串 

july0404的专栏 524

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

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

visio安装包

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

hdoj 1015 Safecracker【DFS】

Safecracker Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10612    Accepted Submission(s): 5429 Problem Description === Op tech b

平平淡淡才是真 769

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

HDOJ P1015 Safecracker

Safecracker Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5302    Accepted Submission(s): 2646 Problem Description === Op tech br

kdwycz的刷题空间 462

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

HDOJ1015 Safecracker【DFS排列】

HDOJ1015 题目 思路 这道题可以抽象为排列问题。 假设有12个字母,要选出5个字母分别代入v-w^2+ x^3 -y^4+ z^5式子里。数学上,这就是一个排列问题,一共有95040种结果。程序上,排列问题可以用dfs解决。 代码 //数组a表示字母对应的int数值 //a[step] = 1表示第step(step范围:1-5)个位置放置的字母是‘A’ //book[i] = 0表示字...

hfut橘生淮南的博客 211

HDOJ1015 Safecracker(DFS,回溯)

HDOJ 1015 这看上去并不像一道DFS的题目,核心代码DFS中也没有搜索下一个结点的四个方向。下面的for循环,很像DFS向4个方向搜索。这里的len代表字符数组的长度。下一个搜索目标,就在这个字符序列中找,找至今还没有被访问过的”!visit[i]”,并且还没有找到解!judge,选完一个字符时,注意visit[i]=0,无后效性。for(i=0;i<len;i++){ i

xx_ii 572

HDOJ HDU 1015 Safecracker

HDOJ 1015 Safecracker题目 点此查看 HDOJ 1015 Digital Roots 分类 dfs 题意 要打开安全锁 密码 由 一个数字 和 一个字符串组成 从给定字符中找 5 个字符 v, w, x, y, z 满足 v - w^2 + x^3 - y^4 + z^5 (A=1, B=2, …, Z=26). 例如 :

Gy_1096440940的博客 479

HDOJ1015.Safecracker

试题请参见: http://acm.hdu.edu.cn/showproblem.php?pid=1015题目概述=== Op tech briefing, 2002/11/02 06:42 CST === “The item is locked in a Klein safe behind a painting in the second-floor library. Klein safes

Infinite Script 2495

HDOJ(HDU).1015 Safecracker (DFS)

HDOJ(HDU).1015 Safecracker [从零开始DFS(2)]题意分析首先默认有个字母到数字的映射,A=1,B=2,C=3 …… Z=26,给出你一个目标数字target,然后给出一串字母,要求从这些字母中选取5个数字vwxyz,满足 v - w^2 + x^3 - y^4 + z^5 = target。可能有多组解,只输出字典序最大的那个。嗨呀一看到这道题,是否有种似曾相识的感觉

Pengwill's Blog 2209

HDOJ 1015 Safecracker

题意: 大致是给一个数 target, 和一个字符串 str, 然后从字符串str 中选择五个字母满足方程v - w^2 + x^3 - y^4 + z^5 = target 即可,但是在此之前需要给字符串排下序(这个地方纠结了好久,在网上看了资料才明白要排序,尼玛) 解题思路:字符串最多才12,果断DFS 水过了。 分类: DFS ,类似于背包问题。 6924...

99

hdoj 1015 Safecracker

Safecracker                                                                  Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description === Op t

逆风飞翔 329
上一篇: poj 3262 Protecting the Flowers
下一篇: hdoj 2438 Turn the corner
SimonCoder
博客等级 码龄13年 1413粉丝 231原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址