1019 General Palindromic Number

SAR成像系列:【3】合成孔径雷达(SAR)的二维回波信号与简单距离多普勒(RD)算法 (附matlab代码) 二维回波信号分析 阅读详情

1019 General Palindromic Number

A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers.

Although palindromic numbers are most often considered in the decimal system, the concept of palindromicity can be applied to the natural numbers in any numeral system. Consider a number N>0 in base b≥2, where it is written in standard notation with k+1digits a​i​​ as ∑​i=0​k​​(a​i​​b​i​​). Here, as usual, 0≤a​i​​<b for all i and a​k​​ is non-zero. Then N is palindromic if and only if a​i​​=a​k−i​​ for all i. Zero is written 0 in any base and is also palindromic by definition.

Given any positive decimal integer N and a base b, you are supposed to tell if N is a palindromic number in base b.

Input Specification:

Each input file contains one test case. Each case consists of two positive numbers N and b, where 0<N≤10​9​​ is the decimal number and 2≤b≤10​9​​ is the base. The numbers are separated by a space.

Output Specification:

For each test case, first print in one line Yes if N is a palindromic number in base b, or No if not. Then in the next line, print N as the number in base b in the form "a​k​​ a​k−1​​ ... a​0​​". Notice that there must be no extra space at the end of output.

Sample Input 1:

27 2

Sample Output 1:

Yes
1 1 0 1 1

Sample Input 2:

121 5

Sample Output 2:

No
4 4 1

回文数问题和进制转换属于机考的常规题,要注意根据数值范围来确定解题方法。如进制转换有常规方法(int内)和大数方法(模拟除法)。

#include<iostream>
using namespace std;
int a[101];
int dec2b(int n,int base,int arr[]){
	int idx=0;
	while(n!=0){
		arr[idx]=n%base;
		n/=base;
		idx++;
	}
	return idx;
}
int b2dec4rev(int arr[],int base,int len){
	int ans=0;
	for(int i=0;i<len;i++){
		ans=ans*base+arr[i];
	}
	return ans;
}
int main(void){
	int n,base;
	cin>>n>>base;
	int len=dec2b(n,base,a);
	int reverse = b2dec4rev(a,base,len);
	if(n==reverse) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	for(int i=len-1;i>=0;i--){
		if(i==len-1) cout<<a[i];
		else cout<<" "<<a[i]; 
	}

	return 0;
	
}

 

百度飞桨EasyDL图像分类:收费口车辆类型自动识别 车辆类型识别在高速收费路口的应用中,场景相对单一且拍摄角度一致,因此首次训练模型效果优异,准确率达到了95%,鉴于市面上的车辆类型不断更新迭代且部分车辆的主要特征也不断发生变化,因此可在模型投入应用后,持续收集模型实际运行过中产生的数据,定期添加数据进行模型迭代,保证模型效果。企业将AI模型应用到实际场景中以实现停车费用、过路费用的自动计算,在收费口中由相机对每个车辆进行拍摄,拍摄到的图片传输到预测设备上进行类型识别,基于识别出来的车辆类型自动进行费用计算。该功能可在发起训练时选选择对应的开关打开即可。.. 阅读详情

相关推荐

WorldQuant Brain Alpha 生成器

一个自动化工具,通过参数优化和回测来挖掘高质量的量化交易 Alpha 因子,并自动提交符合标准的因子。

weixin_37582383的博客 1万+

PAT甲级 1019 General Palindromic Number

PAT甲级 1019 General Palindromic Number A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single...

旺崽的博客 2867

ArcGIS Pro新手避坑:从OpenStreetMap导入路网到创建拓扑关系全流程

本文详细解析了ArcGIS Pro中从OpenStreetMap导入路网数据到创建拓扑关系的全流程,涵盖OSM数据特性、几何完整性检查、属性强化及拓扑关系构建等关键步骤。特别针对路网数据预处理、网络数据集配置和常见问题提供了实用解决方案,帮助GIS新手高效完成网络分析任务。

weixin_33670786的博客 514

PAT甲级1019 General Palindromic Number

PAT 甲级 1019 General Palindromic Number 题目概述:给一个10进制正整数N,和一个base(进制),用base进制来表示这个10进制的数,比如27 2,将27用2进制表示为11011,而11011是回文数,就输出Yes,然后打印1 1 0 1 1,反之输出No,然后打印这几个数 package higherlevel; import java.util.Arr...

优快云_Lrcx的博客 250

什么是无人机巡检?如何实现无人机自动巡检?

复亚智能的无人机自动巡检系统通过高度自动化的技术,实现了无人机的高效巡检作业。无人机自动机场支持无人机的自动起降和电池更换,自动飞行算法确保无人机在复杂环境中的精准飞行和拍摄,而云端识别诊断和AI感知算法平台则实现图像的实时传输和智能分析。复亚智能,作为无人机技术的创新者和推动者,致力于开发先进的无人机自动巡检解决方案,助力各行各业实现智能化、自动化的巡检工作,引领智能巡检的未来。利用人工智能和机器学习算法,无人机可以被训练来识别特定的模式和异常,如结构损坏、热泄漏等,从而提高巡检的准确性和效率。

foiadrone的博客 2844

FPGA上跑100G网卡?手把手教你用Xilinx IP核配置RDMA(附避坑指南)

本文详细介绍了如何在Xilinx UltraScale+ FPGA平台上配置100G RDMA网络加速方案,涵盖CMAC和ERNIC IP核的深度配置技巧、硬件架构设计及系统集成。通过实战指南和避坑建议,帮助开发者实现超低延迟、零拷贝的数据传输,显著提升数据中心和高性能计算的网络性能。

weixin_33734785的博客 677

1019 General Palindromic Number (20 分)

1019General Palindromic Number(20 分) A number that will be the same when it is written forwards or backwards is known as aPalindromic Number. For example, 1234321 is a palindromic number. Al...

weixin_30703911的博客 95

Cgroup对进程所占用的CPU与内存资源同时进行限制的测试

测试环境:Ubuntu。处理器数量:1CPU。内存大小:2048MB。 以下是测试程序mem_cpu_test.c的代码。 将mem_cpu_test.c编译为可以运行的程序mem_cpu_test。 运行程序,并用top命令查看mem_cpu_test所占用的系统资源情况,可以看到,mem_cpu_test使用了50%左右的内存资源,也就是1000MB左右,并占用了接近全部的CPU资源。 关闭以上的程序后,在Cgroup子系统memory和cpu下分别创建进程组test1和test2。 并设置tes

qq_44998067的博客 1154

Day52: [PAT甲级] 1019 General Palindromic Number (20分)

Day52: [PAT甲级] 1019 General Palindromic Number (20分) 题源: 来自PAT真题库: https://pintia.cn/problem-sets/994805342720868352/problems/994805487143337984 代码: dirty code凑合看吧 #include<iostream> #include&l...

qq2215459786的博客 237

生态学家都在用的MixSIAR:用R语言搞定稳定同位素混合模型(从数据整理到结果解读)

本文详细介绍了生态学家常用的MixSIAR工具,通过R语言实现稳定同位素混合模型分析,从数据整理到结果解读全流程。文章涵盖环境准备、模型构建、参数设置、运行诊断及可视化等关键步骤,帮助研究者科学分析河口鱼类食物来源,适用于生态学研究和湿地保护政策制定。

weixin_28683065的博客 439

利用运放设计简单有源滤波器(低通、高通、带通)

本文旨在帮助刚接触模电的同学快速设计一个实用可靠的运放,故我将不会说一些晦涩难懂的原理,只给出仿真电路图。

WeiTong0527的博客 3万+

PAT 1019 General Palindromic Number

PAT 1019 General Palindromic Number 题目 PAT 1019 General Palindromic Number 题解 本题难度不大,主要是考察了一个进制转换问题,请参照我的另一博客 r进制转换 代码 #include <stdio.h> #include <iostream> using namespace std; int main(){ int N,b; cin>>N>>b; int z[100];

m0_45240925的博客 145

基于simulink的软开关技术的三相逆变器仿真

三相逆变器中的软开关技术(Soft Switching Techniques)旨在减少开关损耗,提高效率,并降低电磁干扰(EMI)。实现软开关通常涉及使用谐振电路或准谐振电路来确保开关器件在零电压(Zero Voltage Switching, ZVS)或零电流(Zero Current Switching, ZCS)条件下进行切换。下面将详细介绍如何在Simulink中进行基于软开关技术的三相逆变器仿真设计。

xiaoheshang_123的博客 164

PAT-1019 General Palindromic Number

1019 General Palindromic Number part 1, 1.2 自己解法(未全对) 有一个WA 可惜题目并没有限制base为10进制以内,不然如下用string做巨快 #include <iostream> using namespace std; #include <algorithm> int main() { int N, base; cin >> N >> base; string res =

seven_colors的博客 242

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

1019 General Palindromic Number

1019General Palindromic Number(20 分) A number that will be the same when it is written forwards or backwards is known as aPalindromic Number. For example, 1234321 is a palindromic number. All sing...

yu121380的博客 223

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

PAT甲级 - 1019 General Palindromic Number (20 分)

题目链接:PAT甲级 - 1019 General Palindromic Number (20 分) A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic num...

158

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

PAT (Advanced Level) 1019 General Palindromic Number (20 分) 【Python/C++】【进制转换】

PAT (Advanced Level) 1019 General Palindromic Number (20 分) Python: import sys from math import * str_in = input() a = [int(n) for n in str_in.split()] n = int(a[0]) d = int(a[1]) vis = [0] * 50 k = ...

Irish_Moonshine的博客 282

PAT 甲级 1019 General Palindromic Number

PAT 甲级 1019 General Palindromic Number #include<bits/stdc++.h> using namespace std; int main() { #ifdef LOCAL freopen("input.txt", "r", stdin);//freopen("output.txt", "w", stdout); #endif long long N_10; int base; cin >> N_10 >> b

桂圆儿的仓库 86
上一篇: 1017 Queueing at Bank (25 point(s))
下一篇: 【PAT】Problem List and Solutions (Advanced Level)
coderwait
博客等级 码龄9年 20粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值