n转化为b进制的格式,问你该格式是否为回文数字(即正着写和倒着写一样)
输出Yes或者No
并且输出该格式
又是水题。。。

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring> using namespace std;
const int maxn=;
int a[maxn];
int n,b;
int main()
{
scanf("%d %d",&n,&b);
int cnt=;
int tmp=n;
if(tmp==){
cnt=;
a[]=;
}
while(tmp){
a[cnt]=tmp%b;
//printf("cnt:%d a:%d\n",cnt,a[cnt]);
cnt++;
tmp=tmp/b;
}
bool flag=true;
for(int i=;i<=cnt/;i++){
if(a[i]!=a[cnt--i]){
flag=false;
break;
}
} if(flag)
printf("Yes\n");
else
printf("No\n");
printf("%d",a[cnt-]);
for(int i=cnt-;i>=;i--){
printf(" %d",a[i]);
}
printf("\n");
return ;
}

PAT甲题题解-1019. General Palindromic Number (20)-又是水题一枚的更多相关文章

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

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

  2. 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 ...

  3. 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 ...

  4. 1019 General Palindromic Number (20)(20 point(s))

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

  5. 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 ...

  6. PAT (Advanced Level) 1019. General Palindromic Number (20)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  7. 【PAT甲级】1019 General Palindromic Number (20 分)

    题意: 输入两个正整数n和b(n<=1e9,2<=b<=1e9),分别表示数字的大小和进制大小,求在b进制下n是否是一个回文串,输出“Yes”or“No”,并将数字n在b进制下打印出 ...

  8. 1019. General Palindromic Number (20)

    生词以及在文中意思 forward 向前地 backward 向后地 palindromic 回文的 base 基数(如十进制的10 和二进制的2) numeral system 数制 decimal ...

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

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

随机推荐

  1. NHibernate出现could not execute query问题

    今天在调试代码时工程总报错,提示could not execute query xxxxxxxxxxxxxxxxxxxxxxxxxxx 找了很久,最终同事发现是数据库连接配置文件的问题. <hi ...

  2. php linux 环境搭建

    Apache源于NCSAhttpd服务器,经过多次修改,成为世界上最流行的Web服务器软件之一.Apache取自“a patchy server”的读音,意思是充满补丁的服务器,因为它是自由软件,所以 ...

  3. [Python] 同时安装了python2和python3时,pip命令该如何使用?

    当python2和python3同时安装windows上时,它们对应的pip都叫pip.exe,所以不能够直接使用 pip install 命令来安装软件包. 而是要使用启动器py.exe来指定pip ...

  4. python is、==区别;with;gil;python中tuple和list的区别;Python 中的迭代器、生成器、装饰器

    1. is 比较的是两个实例对象是不是完全相同,它们是不是同一个对象,占用的内存地址是否相同 == 比较的是两个对象的内容是否相等 2. with语句时用于对try except finally 的优 ...

  5. Node.js实战(五)之必备JavaScript基础

    阅读本章的话,个人觉得之前使用过JavaScript,完全轻松. Node.js的核心类型有:number.boolean.string以及object.另外两种类型分别是函数合数组,其实它们你可以理 ...

  6. ssl,proxy;部分http部分https;80,443,8080;nginx+tomcat;

    ..... user nobody; worker_processes 8; error_log /opt/logs/nginx/nginx_error.log crit; pid /usr/loca ...

  7. Qt5中运行后台网络读取线程与主UI线程互交

    项目中有一个需求就是,因为需要请求服务端数据,因为网络的读取会阻塞,所以该过程不能放在Qt中的UI主线程当中,需要用一个后台线程来读取数据,数据准备完毕后 在通过Qt5中的信号槽机制来跨线程的传递数据 ...

  8. JS图片灯箱(lightBox)效果基本原理和demo

    到年底了,项目不怎么忙,所以有空特地研究了下KISSY中源码JS灯箱效果,感觉代码比较简单,所以就按照他们的思路依赖于Jquery框架也封装了一个,特地分享给大家,以前经常看到网上很多这样的插件,感觉 ...

  9. (二) DRF 视图

    DRF中的Request 在Django REST Framework中内置的Request类扩展了Django中的Request类,实现了很多方便的功能--如请求数据解析和认证等. 比如,区别于Dj ...

  10. Java 中long类型转换成为int类型时可能会出错的地方

    那计算两个日期之间间隔的天数为例来说明这个问题. 下面是计算日期间隔天数的简单算法(主要出错的地方为红色标注的地方): public int getDay(String startDate, Stri ...