PAT 1010. Radix (25)

生信物种注释软件Kraken2+Bracken的安装与使用 一、软件安装与数据库下载 1.Kraken2安装 Kraken2是一个基于k-mer算法的高精度宏基因组序列分类软件,能够快速的将测序reads进行物种分类。 使用conda一键安装,要先安装好anaconda或者miniconda conda install -y kraken2 输入krakek2 --help 出现如下所示帮助文档,则表示安装成功。 2.Bracken安装 bracken是一种从宏基因组数据中高度准确的计算物种丰度的统计方法。 同样使用conda一键安装 conda install - 阅读详情

Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is "yes", if 6 is a decimal number and 110 is a binary number.

Now for any pair of positive integers N1 and N2, your task is to find the radix of one number while that of the other is given.

Input Specification:

Each input file contains one test case. Each case occupies a line which contains 4 positive integers:
N1 N2 tag radix
Here N1 and N2 each has no more than 10 digits. A digit is less than its radix and is chosen from the set {0-9, a-z} where 0-9 represent the decimal numbers 0-9, and a-z represent the decimal numbers 10-35. The last number "radix" is the radix of N1 if "tag" is 1, or of N2 if "tag" is 2.

Output Specification:

For each test case, print in one line the radix of the other number so that the equation N1 = N2 is true. If the equation is impossible, print "Impossible". If the solution is not unique, output the smallest possible radix.

Sample Input 1:
6 110 1 10
Sample Output 1:
2
Sample Input 2:
1 ab 1 2
Sample Output 2:
Impossible
题目坑挖的比较多,首先输入数据不超过10位,但是数据的值可能爆32位,需要注意。
其次进制范围没有限定,这表示进制可能很大。
基本思想就是遍历进制。鉴于进制太大,进行二分,防止超时。
如果满足条件的进制不唯一,要求输出最小的进制这点需要认真考虑下,结果是个位数可能出现此情形。
解决好以上几点,这题也就差不多了。


#include<stdio.h>
#include<math.h>
#include<string.h>
char val[128];
int max=0;
long long  to10(char n[],int radix)
{
	long long sum=0;
	int i=0,len=strlen(n);
	for(;i<len;i++)
	{
		sum=sum*radix+val[n[i]];
		if(sum<0)break;
	}
	return sum;
}
int main()
{
	int x=0;
	for(x=48;x<58;x++)val[x]=x-48;
	for(x=65;x<65+26;x++)val[x]=x-55;
	for(x=97;x<97+26;x++)val[x]=x-87;
	long long sum,sum1=0,sum2,sum3,i,k=20000000000;
	char n[2][20];
	int tag,radix;
	scanf("%s%s%d%d",&n[0],&n[1],&tag,&radix);
	for(x=0;x<strlen(n[2-tag]);x++)max=max>val[n[2-tag][x]]?max:val[n[2-tag][x]];
	sum=to10(n[tag-1],radix);
	i=max+1;
	while(1)
	{
		sum1=to10(n[2-tag],i);
		sum2=to10(n[2-tag],(k+i)/2);
		if(sum1>sum||i>k)break;<span style="white-space:pre">	</span>
		if(sum2==sum)
		{
			if(sum<10&&((i+k)/2>(sum+1)))
				printf("%d\n",sum+1);
			else
				printf("%d\n",(i+k)/2);
			return 0;
		}
		else if(sum2>sum||sum2<=0)
		{
			k=(i+k)/2-1;
		}
		else if(sum2<sum)
		{
			i=(i+k)/2+1;
		}
	}
	printf("Impossible\n");
	return 0;
}



        
320x240 TFT屏的SPI DMA驱动避坑指南:基于HC32F460的时序调试心得 本文详细介绍了基于HC32F460 MCU驱动320x240 TFT屏的SPI DMA实战经验,涵盖硬件设计、波形诊断、DMA优化及高级调试技巧。重点解析SPI时序配置、DMA缓冲区对齐等常见问题,并提供逻辑分析仪波形诊断方法和性能优化策略,帮助开发者规避典型陷阱,提升显示性能。 阅读详情

相关推荐

K8S 1.28.2 + Calico 3.27.3 保姆级安装避坑指南:解决节点NotReady问题

本文提供了一份详细的Kubernetes 1.28.2与Calico 3.27.3集群部署指南,重点解决节点NotReady这一常见问题。通过版本兼容性分析、精细化环境配置、kubeadm初始化参数详解及Calico Operator部署,手把手指导用户避开网络插件配置陷阱,确保集群从NotReady状态恢复健康并稳定运行。

weixin_28835583的博客 392

【逻辑】1010 Radix

1010 Radix (25 分) Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number. Now for any pair of positive integers N1 and N2 , your task is to find t

weixin_45836276的博客 341

有关SPSS中Fisher精确检验无法进行的解决方法(由于无法打开临时文件,因此无法进行计算)

最近在帮一个四年生完成她的毕业论文,在用SPSS进行R×C表检验的时候,发现Fisher精确检验的结果无法显示,提示为“由于无法打开临时文件,因此无法进行计算”,大概像下图一样。 (这图是从网上找的) 然...

chuyang37的博客 3万+

【PAT甲级A1010 】1010 Radix (25分)(c++)

1010 Radix (25分) 作者:CHEN, Yue 单位:浙江大学 代码长度限制:16 KB 时间限制:400 ms 内存限制:64 MB Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number. Now for any pair

小庄同学的博客 367

向量数据库安全实战:从Embedding反推到检索越权的全链路防护

随着RAG应用在企业中的普及,向量数据库已成为知识库系统的核心组件。但许多团队对向量数据的安全认知仍停留在传统数据库的账号密码、网络隔离和磁盘加密上。事实上,向量化并非加密,而是一种有损压缩的语义映射,向量本身可以被反推模型还原出原文关键信息,形成高保真的语义泄露通道。同时,相似度检索的模糊匹配特性打破了传统行列权限模型,使得越权检索和成员推断攻击成为新的安全威胁。理解这些原理,有助于企业在数据采集、向量化、索引构建、检索查询等环节构建分层防护体系,包括脱敏、扰动、过滤下推、网关控制等手段。本文从基础概念出

weixin_29323551的博客 258

假新闻检测论文分享(17)CAFE(Cross-modal Ambiguity Learning for Multimodal Fake NewsDetection)

本文首先从信息论的角度对跨模态歧义性学习问题进行形式化描述,利用不同单模态特征之间的分布散度量化其歧义性;然后,提出了一种模糊度感知的多模态假新闻检测方法CAFE。CAFE通过自适应地聚合单模态特征和跨模态关联,即在跨模态歧义性较弱时依赖单模态特征,在跨模态歧义性较强时参考跨模态关联,从而提高假新闻检测精度。提出了跨模态歧义学习问题,这是多模态假新闻检测的一个关键挑战,并提出了一种基于KL散度的方法,通过估计其特征分布的散度来量化文本和图像之间的歧义。

weixin_41964296的博客 1724

PAT 1010(二分法)

1010Radix(25分) Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer isyes, if 6 is a decimal number and 110 is a binary number. Now for any pai...

Ariel_x的博客 402

YOLOv11低光照检测性能优化:基于Retinexformer主干网络的深度改进实践

购买即可解锁300+YOLO优化文章,并且还有海量深度学习复现项目,价格仅需两杯奶茶的钱,别人有的本专栏也有!@[TOC]在自动驾驶、安防监控、遥感探测等关键领域,目标检测系统必须保证24小时全天候的可靠工作。然而,现有最先进的目标检测模型,包括YOLOv11,其训练数据大多源于光照良好的场景。当环境光照条件急剧下降时,图像会出现严重的噪声、低对比度、颜色失真和细节丢失,直接导致模型性能断崖式下跌。常规的解决方案如图像直方图均衡化或简单的伽马校正,往往收效甚微,甚至可能放大噪声,进一步干扰检测。

m0_71589036的博客 189

PAT练习题 P1010 Radix (25分)【二分匹配】

传送门:P1010 P1010 Radix (25分) Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number. No...

Waiting For You 299

基于Simulink的伺服电机位置闭环控制仿真

本文带你从零构建了伺服电机位置闭环控制系统​ 的完整Simulink仿真模型,实现了:✅ 搭建PMSM伺服电机、逆变器、机械臂负载的主电路与编码器反馈模型;✅ 用MATLAB Function实现三环控制(位置环PID、坐标变换、电流环PI);✅ 验证阶跃定位(稳态误差0.002°、响应0.08s)与正弦跟踪(误差0.008°)的高性能;✅ 对比开环控制,明确位置闭环在精度、响应、抗扰上的优势;✅ 理解“三环嵌套+反馈校正”的核心思想(精密定位的工程实现)。核心收获。

amy_mhd的博客 173

Windows 下 Codex 安装全记录:从零到一的保姆级图文教程

本文主要介绍了Windows 下 Codex 安装全记录:从零到一的保姆级图文教程,希望能对学习使用 Codex 的同学们有所帮助。 文章目录 1. 背景 2. 实战教程 2.1 方案一 2.2 方案二 3. 报错解决方案

weixin_43178406的博客 14万+

PAT A1010 Radix(细节很多的一道题)

原题目描述为: Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number. Now for any pair of positive integers N​1 and N​2 , your task is to find the radi

lvonge的博客 318

ATS Request中的PASID的作用是什么

摘要: PASID(进程地址空间标识符)是PCIe ATS(地址转换服务)中的关键组件,用于标识不同进程或虚拟机的地址空间。其主要作用包括:1)支持多进程共享设备时隔离地址空间;2)实现共享虚拟地址(SVA),允许用户态程序直接访问设备;3)提升虚拟化性能(如SIOV),通过PASID区分虚拟机请求;4)增强安全性,基于PASID限制设备内存访问权限。PASID通过20位标识符在TLP前缀中传递,与IOMMU协作完成地址转换与缓存,适用于高性能计算、AI及虚拟化场景,但依赖硬件支持和软件适配。

元直的博客 1560

【PAT甲级】1010 Radix (25 分)

1010 Radix 题目描述 Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number. Now for any pair o...

初见还是重逢的博客 1137

精雕软件(JDpaint) 5.5 绿色版

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

visio安装包

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

[PAT] 1010 Radix (25 分)Java

Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number. Now for any pair of positive...

Simma1101的博客 248

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

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

PAT 1010 Radix (25分)

Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number. Now for any pair of positive integers N1N_1N1​​​ and N2N_2N2​, your task is to find the ra

Avatar_Unique的博客 174

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

PAT 甲级1010 Radix (25 分)

1010Radix(25分) Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer isyes, if 6 is a decimal number and 110 is a binary number. Now for any pa...

Dexter 279

PAT甲级1010 Radix (25分)

PAT甲级1010 Radix (25分) 题目: 题目分析:运用二分法来处理 AC代码附上: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long ll; ll map[256];//0~9,a~z,和0~35对应 ll ...

weixin_43795683的博客 343

[PAT-Advanced] A1010 Radix (25)

文章目录A1010 Radix (25point(s))Input Specification:Output Specification:Sample Input 1:Sample Output 1:Sample Input 2:Sample Output 2:CodeAnalysis Author: CHEN, Yue Organization: 浙江大学 Time Limit: 400 ms ...

Duke 315

PAT A1010 Radix (25分)

#include <cstdio> #include <cstring> #include <algorithm> typedef long long LL; using namespace std; LL MAX = (1LL << 63) - 1; char n1[11], n2[11]; int tag, r; LL map[256]; void init(){ for(char c='0'; c<='9'; c++){ map[c.

weixin_45964844的博客 282

PAT甲级 1010 Radix (25分)

1010 Radix (25分) 题目链接: PAT A 1010 这道题难度比较大,而且测试点还非常多,我debug就花了一天时间,尽量为大家讲解的清楚一些吧。 思路分析:这题给两个数和其中一个数的进制,要找出另外一个数是什么进制的时候使得这两个数相等。注意题目里数位的范围是0-35,但是这个进制不一定小于36,而是从2到int最大值甚至是long long最大值的任意一个数,比如1可以是二进...

weixin_43684054的博客 364

PAT 1010 Radix (25 分)

1010 Radix (25 分) Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number. Now for any pair...

peanWang的博客 222

PAT 1010 Radix (25)

1010 Radix (25)(25 分) Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number. Now for an...

ryo_218的博客 329

1010 Radix (25分) PAT甲级 Java 实现

1010 Radix (25分) PAT甲级 Java 实现 文章目录1010 Radix (25分) PAT甲级 Java 实现1 题目2 解题思路2.1 题目大意2.2 题目细节2.3 解题思路3 代码 1 题目 题目链接 https://pintia.cn/problem-sets/994805342720868352/problems/994805507225665536 Given a pair of positive integers, for example, 6 and 110, can

qq_38650754的博客 278

PAT甲级 - 1010 Radix (25 分)

题目链接:PAT甲级 - 1010 Radix (25 分) Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number. N...

174

PAT 甲级 1010 Radix (25分)

题目 1010 Radix (25分) Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number. Now for any pair of positive integers N1 and N2, your task is to find

qq_41001689的博客 184
上一篇: PAT 1049 Counting Ones
下一篇: PAT 1073 Scientific Notation
chamsu
博客等级 码龄14年 78粉丝 32原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值