浙江大学PAT_甲级_1019. General Palindromic Number (20)

我用 AI 做了个开源地图工具:从 OpenStreetMap 一键获取全国 AOI/POI 数据 本文介绍了一款免费开源的OSM数据查询与可视化工具,旨在解决Overpass QL语法晦涩、数据获取门槛高的问题。工具支持面数据(AOI)、点数据(POI)及路网三种查询模式,内置30+常用模板实现一键检索。具备高德与OSM双底图切换、坐标自动转换功能,支持GeoJSON、SHP、CSV多格式导出,同时保留自定义查询能力。作为纯HTML单文件应用,可零成本部署至GitHub Pages在线使用。该工具有效降低了地理数据获取难度,是替代商业地图API、高效提取全球开源地理信息的实用利器。 阅读详情

题目链接:点击打开链接

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+1 digits ai as the sum of (aibi) for i from 0 to k. Here, as usual, 0 <= ai < b for all i and ak is non-zero. Then N is palindromic if and only if ai = ak-i for all i. Zero is written 0 in any base and is also palindromic by definition.

Given any non-negative 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 non-negative numbers N and b, where 0 <= N <= 109 is the decimal number and 2 <= b <= 109 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 "ak ak-1 ... a0". 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
我的C++c程序:

#include<iostream>
#include<vector>
#include<stack>
using namespace std;
bool check(vector<int> vec)//判断vector里的数是否为回文,是返回1
{
	int left = 0, right = vec.size() - 1;
	while (left <= right)
	{
		if (vec[left] != vec[right])
		{
			return 0;
		}
		left++;
		right--;
	}
	return 1;
}
vector<int> transform(long long n, long long d)//将10进制数转换为D进制,并将各位存储到vector里
{
	stack<int>sta;
	vector<int>vec;
	while (n != 0)
	{
		sta.push(n%d);
		n = n / d;
	}
	while (!sta.empty())
	{
		vec.push_back(sta.top());
		sta.pop();
	}
	return vec;//返回一个vector
}
int main()
{
	vector<int> vec;
	long long n, d;//n一个数,d转换后的进制
	cin >> n >> d;
	if (n == 0||n==1||n==2)//0 1 2在任何进制都是回文数
	{
		cout << "Yes"<<endl;
		cout <<n;
		return 0;
	}
	vec = transform(n, d);//进制转换
	if (check(vec))//检查回文数
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	for (int i = 0;i < vec.size()-1;i++)//输出回文数
	{
		cout << vec[i]<<' ';
	}
	cout << vec[vec.size() - 1];//输出回文数最后一位
	//system("pause");
	return 0;
}


对接金蝶云星空调用即时库存信息查询API(附JAVA实现) 这篇文章教你如何对接金蝶API并且使用JAVA调用金蝶云星空的即时库存查询API 阅读详情

相关推荐

别急着做AI:FDE教你识别真需求,让AI真正落地

人工智能项目在落地过程中,经常出现业务方高喊“我们要做AI”,却说不清具体应用场景的现象。判断一个需求是否值得用AI实现,不能只看技术流行度,而要从问题出现频率、当前替代方案以及可量化业务价值三个维度展开验证。同时需要冷静比较规则引擎与大模型的边界:不是所有语义任务都要靠生成式模型,稳定、可解释且低成本的传统方案往往更具工程性价比。数据闭环也至关重要,缺乏历史样本与反馈回流路径的项目,很难在真实环境中持续优化。针对智能客服、合同审查或企业知识库等典型场景,可借助人机协同与最小代价的用户验证,逐步筛除伪需求,

weixin_42624889的博客 348

[PAT-甲级]1019.General Palindromic Number

1019. General Palindromic Number (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A number that will be the same

CVer 1691

OSMDroid(1)——OSM简介,基础例子搭建

1.OSMDroid简介 Osmdroid是一款完全开源的地图基本操作SDK,相比于现在普遍使用的百度地图,高德地图,谷歌地图等最大的好处就是开源。 最近在做一个军方项目,要求完全不能联网,从开发到应用整个阶段都是在局域网进行,相比之下采用了OSMDroid这个SDK作为解决方案。 先来看OSMDroid,便是(OpenStreetMapForAndroid),后面都简称OSM...

robotskly的博客 6191

【PAT甲级A1019】General Palindromic Number(20分)(c++)

1019 General Palindromic Number (20分) 作者:CHEN, Yue 单位:浙江大学 代码长度限制:16 KB 时间限制:400 ms 内存限制:64 MB 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 singl

小庄同学的博客 185

python爬取巨潮资讯网所有股票年报数据

爬虫获取巨潮资讯网数据

qq_42752524的博客 6184

「极简」扣子(coze)教程 | 细节决定成败!这个小功能让用户满意度飙升,讲的太细了

这一期大师兄通过向扣子(coze)应用添加提示语的方法向用户显示系统运行的状态。

u014527622的博客 2133

PAT甲级 1019 General Palindromic Number

进制可能大于10,所以要用数组存a GitHub - ZouJiu1/PAT: 浙江大学PAT题目解答内容浙江大学PAT题目解答内容. Contribute to ZouJiu1/PAT development by creating an account on GitHub.https://github.com/ZouJiu1/PAT

邹九的个人博客 150

SAP GR(Group Reporting)配置篇(一)

GUI组报表的SAP S4HANA1.1全局参数1.1.1 检查全球系统设置菜单路径组报表的SAP S4HANA>合并的全局设置>检查全球系统设置事务代码CXB3说 明定义好分类账、版本、合并科目表后,重新设置。1.2主数据1.2.1定义合并分类账菜单路径组报表的SAP S4HANA>主数据>定义合并分类账事务代码CXL2说 明复制的Y1合并分类账,集团货币为CNY。此功能对分类账进行设置,应用到集团货币分类。

weixin_43853754的博客 1709

PAT 甲级 1019 General Palindromic Number(20 分)

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 number. All singl...

宝付支的博客 339

Lammps实现Ar的沸腾过程(包含in文件)

Lammps实现简单的沸腾过程

Rockyoung 3511

SAP-ABAP:在SAP系统中,COEP表(成本控制对象行项目表)详解

在SAP系统中,COEP表(成本控制对象行项目表)详解

baidu_35680696的博客 1850

浙江大学PAT_甲级_1094. The Largest Generation (25)

题目链接:点击打开链接 A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest po

~~(v_v)~~ 1240

【ARM CoreLink 系列 3 -- CCI-550 控制器介绍 】

Arm CoreLink CCI-550 Cache Coherent Interconnect 扩展了 CoreLink CCI-500。它在 big.LITTLE 处理器集群之间提供完整的缓存一致性,并为其他代理(如 Mali GPU、网络接口或加速器)提供 I/O 一致性。CoreLink CCI-550 提供可扩展和可配置的互连,使 SoC 设计人员能够以尽可能小的面积和功耗满足性能目标,并且还增加了可降低整体系统延迟的监听滤波器。

CodingCos的博客 2215

PAT_甲级_1001. A+B Format (20)

1001. A+B Format (20)   Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits). Input...

~~(v_v)~~ 1172

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

visio安装包

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

浙江大学PAT_甲级_1005.1005. Spell It Right (20)

c++实现

~~(v_v)~~ 991

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

浙江大学PAT_甲级_1032. Sharing (25)

题目地址:点击打开链接 To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suf

~~(v_v)~~ 778

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

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

PAT_甲级_1029. Median (25)

题目链接:点击打开链接   Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1={11, 12, 13, 14} is 12, and the median of S2={9, 10, 15, 16...

~~(v_v)~~ 746

浙江大学PAT_甲级_1035. Password (20)

C++

~~(v_v)~~ 736

浙江大学PAT_甲级_1081. Rational Sum (20)

题目链接:点击打开链接 Given N rational numbers in the form "numerator/denominator", you are supposed to calculate their sum. Input Specification: Each input file contains one test case. Each case sta

~~(v_v)~~ 730

浙江大学PAT_甲级_1023. Have Fun with Numbers (20)

python

~~(v_v)~~ 721

浙江大学PAT_甲级_1036. Boys vs Girls (25)

C++

~~(v_v)~~ 715

PAT_甲级_1065. A+B and C (64bit) (20)

题目链接:点击打开链接   Given three integers A, B and C in [-263, 263], you are supposed to tell whether A+B &gt; C. Input Specification: The first line of the input gives the positive number of test cases,...

~~(v_v)~~ 706

浙江大学PAT_甲级_1070. Mooncake (25)

题目链接:点击打开链接 Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the regio

~~(v_v)~~ 687

浙江大学PAT_甲级_1028. List Sorting (25)

C++

~~(v_v)~~ 678

浙江大学PAT_甲级_1058. A+B in Hogwarts (20)

python2,C++

~~(v_v)~~ 644

浙江大学PAT_甲级_1041. Be Unique (20)

C++ map

~~(v_v)~~ 639
上一篇: 浙江大学PAT_甲级_1036. Boys vs Girls (25)
下一篇: 浙江大学PAT_甲级_1041. Be Unique (20)
pythontojava
博客等级 码龄12年 84粉丝 140原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址