题意:

输入两个正整数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. Centos7 ISCSI配置 完全攻略

    Centos7 ISCSI配置 完全攻略 一. iscsi简单介绍 iSCSI( Internet Small Computer System Interface 互联网小型计算机系统接口) iscs ...

  2. django+vue 基础框架 :vue

    <template> <div> <p>用户名:<input type="text" v-model="name"&g ...

  3. Ubuntu 国内安装 kubernetes

    由于墙的原因,国内要安装 kubernetes 非常的麻烦,因此只要解决这个问题,就可以顺利安装 kubernetes 的 三个官法工具 kubelet.kubeadm.kubectl. 安装环境: ...

  4. HBuilder笔记

    官网: https://uniapp.dcloud.io/quickstart HBuilderX - 高效极客技巧 https://ask.dcloud.net.cn/article/13191 插 ...

  5. Java面向对象编程 -6.3

    foreach迭代输出 对于数组而言,一般都会使用for循环进行输出,但是在使用传统for循环的时候往往采用下标的形式进行数组元素的访问. 但是在jdk1.5之后为了减轻下标对数组的影响(如果数组下标 ...

  6. tensorflow 学习记录

    函数变动 tf.train.SummaryWriter 变为 tf.summary.Filewritter 函数功能相同,仅仅是简单的重命名 ``` writer = tf.summary.FileW ...

  7. P1579

    AC: #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < b ...

  8. idea如何提取变量(拆分变量赋值和声明)

    需求描述: 我们时常遇到某个在某个局部作用域声明的变量,想要用在另一个地方,此时就需要在作用域外部声明变量,在作用域中给变量赋值. 在eclipse中这个功能和提取变量在一起,我们可以方便的拆分变量的 ...

  9. PHP的isset(),is_null,empty()你了解了没?

    这几个变量判断函数在PHP开发中用的其实挺多的,而且粗看上去都差不多,但其实还是有不少的区别的,如果搞不清楚,也许就会遗留一些潜在的bug, 包括我自已也遇到过这样的坑,比如有一次我就遇到过用empt ...

  10. iOS中的主要框架framework

    在日常的iOS项目开发中,主要使用的就是Foundation和UIKit这两个框架. (一)Foundation框架 Foundation是对Core Foundation框架的一个封装,使用Foun ...