简单题。

#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<vector>
using namespace std; int s[],tot;
int n,b; bool check()
{
for(int i=; i<=tot/; i++)
{
if(s[i]!=s[tot-i-]) return ;
}
return ;
} int main()
{
scanf("%d%d",&n,&b);
if(n==)
{
printf("Yes\n");
printf("0\n");
}
else
{
tot=;
while(n) s[tot++]=n%b,n=n/b;
if(check()) printf("Yes\n");
else printf("No\n");
for(int i=tot-; i>=; i--)
{
printf("%d",s[i]);
if(i>) printf(" ");
else printf("\n");
}
}
return ;
}

PAT (Advanced Level) 1019. General Palindromic Number (20)的更多相关文章

  1. PTA (Advanced Level) 1019 General Palindromic Number

    General Palindromic Number A number that will be the same when it is written forwards or backwards i ...

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

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

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

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

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

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

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

  7. 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 (20)-又是水题一枚

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

  9. 1019. General Palindromic Number (20)

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

随机推荐

  1. [code]最长回文子串

    分析: 不能用scanf("%s"),因为碰到空格或者Tab就会停下来. 解决输入中有空格 方法一:使用fgetc(fin),读取一个打开的文件fin,读取一个字符,然后返回一个i ...

  2. vb6 控件未注册问题解决

    打开项目时弹出如题错误. 另附一个帖子:http://bbs.csdn.net/topics/390580540,这个帖子讨论的不错,可以提供很多思路. 解决办法:http://rewwensoftw ...

  3. java 数组变量与数组对象

    数组是否必须初始化 对于这个问题,关键在于要弄清楚数组变量和数组对象的差别.数组变量是存放在栈内存中的,数组对象是存放在堆内存中的.数组变量只是一个引用变量,他能够指向实际的数组对象. 所谓的数组初始 ...

  4. 第一次安装ubuntu要设置的东西

    1. 安装网卡驱动 lscpi 查看网卡型号 根据型号找到驱动源码 下载下来并编译 安装 2. 编译安卓源码的时候出现jdk型号不对的情况 把/usr/bin/java 删除,就可以了.

  5. ignite服务中的bean注入为空

    在写ignite服务的时候,通常服务配置在启动文件中: <bean class="org.apache.ignite.services.ServiceConfiguration&quo ...

  6. perfect-scrollbar示例

    <!DOCTYPE html> <html> <head> <title>perfect-scrollbar - www.97zzw.com -97站长 ...

  7. Socks

    Socks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output ...

  8. checking for known struct flock definition... configure: error: Don't know how to define struct flock on this system, set --enable-opcache=

    在对php进行安装的过程中出现如下错误: 1.报错信息: 1 checking for known struct flock definition... configure: error: Don't ...

  9. sqlserver2008行锁

    select * from tablename WITH (UPDLOCK) where Id=#value#

  10. Android Camera(二)

    上次已经写过SurfaceView显示Camera摄像了,代码可以运行,但是里面有问题,这次纠正过来,顺便实现变焦: 代码: public class CameravedioActivity exte ...