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. 一、Ajax 二、JSON数据格式 三、Ajax+Jquery 四、分页的实现

    一.Ajax概述###<1>概述 ###<2>组成 以XMLHttpRequest为核心,发送Ajax请求和接收处理结果 以javascript为语言基础 以XML/JSON作 ...

  2. FZU Monthly-201903 获奖名单

    FZU Monthly-201903 获奖名单 冠军: 黄海东 S031702647 一等奖: 林闽沪 S131700309 陈华能 S221701416 二等奖: 鲍子涵 S031702646 吴少 ...

  3. python第三十课--异常(with as操作)

    演示with...as...操作 path=r'kaifanglist1.txt' with open(path,'r',encoding='utf-8') as fr: print(fr.read( ...

  4. Scala学习之路 (十)Scala的Actor

    一.Scala中的并发编程 1.Java中的并发编程 ①Java中的并发编程基本上满足了事件之间相互独立,但是事件能够同时发生的场景的需要. ②Java中的并发编程是基于共享数据和加锁的一种机制,即会 ...

  5. AES块加密与解密

    AES块加密与解密 解密目标 在CBC和CTR两种模式下分别给出十篇加密的样例密文,求解密一篇特定的密文 解密前提 全部密文及其加密使用的key都已给出 加密的方法遵循AES的标准 解密过程分析 实验 ...

  6. 如何将tensor的内容输出到文本文件

    local part2 = self.convModel:forward({linputs, rinputs}) ) local file = io.open('/home/xbwang/Deskto ...

  7. OpenCV——霍夫变换(直线检测、圆检测)

    x #include <opencv2/opencv.hpp> #include <iostream> #include <math.h> using namesp ...

  8. 利用ngx_python模块嵌入到Python脚本

    导读 Python是一种计算机程序设计语言.是一种动态的.面向对象的脚本语言,最初被设计用于编写自动化脚本(shell),随着版本的不断更新和语言新功能的添加,越来越多被用于独立的.大型项目的开发. ...

  9. JavaScript中的箭头函数

    1.定义 箭头函数相当于匿名函数,并且简化了函数定义.箭头函数有两种格式,一种像上面的,只包含一个表达式,连{ ... }和return都省略掉了.还有一种可以包含多条语句,这时候就不能省略{ ... ...

  10. MVC 全局拦截aciton

    上篇:MVC 拦截指定的action 有时,我们需要对所有aciton在执行前/后做一些(预)处理,如何实现呢? 1.定义一个action筛选类.继承至System.Web.Mvc.IActionFi ...