题意:

输入两个正整数n和b(n<=1e9,2<=b<=1e9),分别表示数字的大小和进制大小,求在b进制下n是否是一个回文串,输出“Yes”or“No”,并将数字n在b进制下打印出来,用空格间隔开每一位数字。

AAAAAccepted code:

 #include<bits/stdc++.h>
using namespace std;
int a[];
int main(){
int n,b;
cin>>n>>b;
int cnt=;
while(n){
a[++cnt]=n%b;
n/=b;
}
int flag=;
for(int i=;i<=cnt/;++i)
if(a[i]!=a[cnt-i+])
flag=;
if(!flag)
cout<<"Yes"<<"\n";
else
cout<<"No"<<"\n";
for(int i=cnt;i>;--i)
cout<<a[i]<<" ";
cout<<a[];
return ;
}

【PAT甲级】1019 General Palindromic Number (20 分)的更多相关文章

  1. PAT Advanced 1019 General Palindromic Number (20 分)

    A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...

  2. PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642 题目描述: A number that will ...

  3. PAT 甲级 1019 General Palindromic Number (进制转换,vector运用,一开始2个测试点没过)

    1019 General Palindromic Number (20 分)   A number that will be the same when it is written forwards ...

  4. PAT 甲级 1019 General Palindromic Number(简单题)

    1019. General Palindromic Number (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...

  5. PAT 甲级 1019 General Palindromic Number(20)(测试点分析)

    1019 General Palindromic Number(20 分) A number that will be the same when it is written forwards or ...

  6. PAT甲级——1019 General Palindromic Number

    A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...

  7. PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) (进制转换,回文数)

    A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...

  8. PAT 甲级 1019 General Palindromic Number

    https://pintia.cn/problem-sets/994805342720868352/problems/994805487143337984 A number that will be ...

  9. 1019 General Palindromic Number (20 分)

    A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...

随机推荐

  1. JEECG开发第一个菜单显示设备列表

    一.新建设备表(t_base_device) ; -- ---------------------------- -- Table structure for t_base_device -- --- ...

  2. Validation failed for one or more entities. See ‘EntityValidationErrors

    try{ context.SaveChanges(); } catch (DbEntityValidationException ex) { var errorMessages = ex.Entity ...

  3. API接收数据反序列化失败问题查找

    C# API接收到数据后,反序列化后直接返回null,而不会给出错误提示,所以不好排查错误. 通过在api中直接进行反序列化,能够得到错误明细: 没有报错的时候,request会直接为null,不会报 ...

  4. Android9 http网络请求的问题

    Google表示,为保证用户数据和设备的安全,针对下一代 Android 系统(Android P) 的应用程序,将要求默认使用加密连接,这意味着 Android P 将禁止 App 使用所有未加密的 ...

  5. cc攻击怎么防御,如何防止cc攻击?

    当我们访问一个网站时,如果网站页面越简单,访问速度越快,页面越漂亮,加载速度就越慢,因为要加载更多东西,服务器压力也会比较大.cc攻击就是利用这种弱点,使用大量代理服务器,对网站进行攻击,消耗网站服务 ...

  6. 【C语言】编写程序,输出以下图形

    编写程序输出以下图形: * ** *** **** ***** 代码: #include <stdio.h> int main() { int i, j; ; i <= ; i++) ...

  7. hadoop学习笔记(一):NameNade持久化和DataNode概念

    其中的fsimage 称为时点备份,又叫磁盘镜像快照,这个是NameNode的一个 持久化的方式之一:缺点,在内存数据序列化的时候比较慢 具体的过程:因为我们所知道的NameNode一般是存储在内存中 ...

  8. phpRedis函数使用总结【分类详细】

    <?php /*1.Connection*/ $redis = new Redis(); $redis->connect('127.0.0.1',6379,1);//短链接,本地host, ...

  9. SpringCloud或SpringBoot+Mybatis-Plus利用mybatis插件实现数据操作记录及更新对比

    引文 本文主要介绍如何使用mybatis插件实现拦截数据库操作并根据不同需求进行数据对比分析,主要适用于系统中需要对数据操作进行记录.在更新数据时准确记录更新字段 核心:mybatis插件(拦截器). ...

  10. 惠普笔记本,如何选择U盘启动

    开机先连续点击键盘F9按键进入选择启动盘界面,找到自己的U盘(KingstonDataTraveler G3)