PAT甲题题解-1019. General Palindromic Number (20)-又是水题一枚
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)-又是水题一枚的更多相关文章
- PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642
PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642 题目描述: A number that will ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- PAT (Advanced Level) 1019. General Palindromic Number (20)
简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...
- 【PAT甲级】1019 General Palindromic Number (20 分)
题意: 输入两个正整数n和b(n<=1e9,2<=b<=1e9),分别表示数字的大小和进制大小,求在b进制下n是否是一个回文串,输出“Yes”or“No”,并将数字n在b进制下打印出 ...
- 1019. General Palindromic Number (20)
生词以及在文中意思 forward 向前地 backward 向后地 palindromic 回文的 base 基数(如十进制的10 和二进制的2) numeral system 数制 decimal ...
- PAT 甲级 1019 General Palindromic Number(简单题)
1019. General Palindromic Number (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
随机推荐
- SQL 性能不佳的几个原因
•不准确的统计数据•差劲的索引•差劲的查询设计 •差劲的执行计划,通常是由不正确的参数引起的•过度阻塞和死锁 •非基于集合的操作•不良数据库设计 •过度碎片 •不能重复使用执行计划 •查询频繁重编译 ...
- windows 2012 抓明文密码方法
windows 2012 抓明文密码方法 默认配置是抓不到明文密码了,神器mimikatz显示Password为null Authentication Id : 0 ; 121279 (0000000 ...
- VGA、DVI、HDMI、DP 接口介绍及优劣
VGA.DVI.HDMI.DP 接口介绍及优劣 随着日新月异的发展,就目前显卡上面常见的输出接口而言,我们所熟知的有以下几种: VGA.DVI.HDMI和DP (DisplayPort). 这四种 ...
- Oracle 12C Data Gurad RAC TO RAC
Oracle 12C RAC TO RAC Data Guard on RHEL7 0.环境说明 primary db physical standby 操作系统 rhel7 x86_64 rhe ...
- bip32
https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki RECENT CHANGES: (16 Apr 2013) Added p ...
- [转]在C++中容易出现的#error No Target Architecture
项目环境:win 7 64位,编译环境:VS2013 最近在写C++的项目,发现了自己很多不会的地方,这也使得我在C++中的成长变得比较快,下面我就说说我自己在写项目是遇到的一些问题,希望可以帮到一些 ...
- XML 读写(XmlDocument、XPathNavigator、XDocument)
内存中的 XML 处理 基于流的 XML 处理提供了最小的负载,但也只提供了最小的灵活性.在很多 XML 处理场景里,你不会在这么低的层次下工作. 对内存中的 XML 的处理则更加方便,但没有单一.标 ...
- 关于Flume中Chanel.Selector.header解释
flume内置的ChannelSelector有两种,分别是Replicating和Multiplexing. Replicating类型的ChannelSelector会针对每一个Event,拷贝到 ...
- 6-51单片机ESP8266学习-AT指令(8266TCP服务器--做自己的AndroidTCP客户端发信息给单片机控制小灯的亮灭)
http://www.cnblogs.com/yangfengwu/p/8776712.html 先把源码和资料链接放到这里 链接: https://pan.baidu.com/s/1jpHZjW_7 ...
- Codeforces round 1106
Div 2 536 题目链接 我还是太菜了.jpg E 傻逼DP直接做 我居然调了1.5h 我真的是太菜了.jpg 堆+扫描线直接维护每个位置的贪心结果 然后要么使用干扰 要么就接受贪心的结果 #in ...