PAT (Advanced Level) 1019. General Palindromic Number (20)
简单题。
#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)的更多相关文章
- 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 ...
- 【PAT甲级】1019 General Palindromic Number (20 分)
题意: 输入两个正整数n和b(n<=1e9,2<=b<=1e9),分别表示数字的大小和进制大小,求在b进制下n是否是一个回文串,输出“Yes”or“No”,并将数字n在b进制下打印出 ...
- 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甲题题解-1019. General Palindromic Number (20)-又是水题一枚
n转化为b进制的格式,问你该格式是否为回文数字(即正着写和倒着写一样)输出Yes或者No并且输出该格式又是水题... #include <iostream> #include <cs ...
- 1019. General Palindromic Number (20)
生词以及在文中意思 forward 向前地 backward 向后地 palindromic 回文的 base 基数(如十进制的10 和二进制的2) numeral system 数制 decimal ...
随机推荐
- beego: 获取request参数
beego提供了一套web开发的框架.但我们在开发过程中遇到了一些问题,现汇总如下. 测试1:测试只有keys数组的情况 func (this *TestController) Index() { k ...
- 自定义AccessDeniedHandler
在Spring默认的AccessDeniedHandler中只有对页面请求的处理,而没有对Ajax的处理.而在项目开发是Ajax又是我们要常用的技术,所以我们可以通过自定义AccessDeniedHa ...
- php 控制循环
控制结构语法 endif.endswitch.endwhile.endfor.endforeach
- oracle数据库的数据类型
一.字符类型 (1)固定长度的字符串 CHAR(字节长度是1~2000之间) CHAR(8)可以存储4个双字节的字符,8个单字节的字符,不足8字节剩余的部分用空格占据 (2)可变长度字符串 VARCH ...
- 点击按钮颜色变深.通过ColorFilter ColorMatrix
private ImageButton imgeBtn; // 颜色矩阵 public final float[] BT_SELECTED = new float[] { 1, 0, 0, 0, -5 ...
- sql数据库删除表的外键约束(INSERT 语句与 FOREIGN KEY 约束"XXX"冲突。该冲突发生于数据库"XXX",表"XXX", column 'XXX)
使用如下SQL语句查询出表中外键约束名称: 1 select name 2 from sys.foreign_key_columns f join sys.objects o on f.constra ...
- ng-init小解
ng-init可有多个表达式 ng-init= "a= 1;b= 2" 在这里头定义的变量会加入scope作用域 ng-init只能加入不必要的简单逻辑,输入alert() 定义数 ...
- 设置UITabBarController上ImageInsets后点击不断缩小
最近遇到了这样一个情况,客户要求做出这种效果的UITabBarController. 通过各种查询,得出UITabBarController有这样一个属性,是设置它的图片距上下左右距离的属性: nav ...
- Dominating Patterns
Dominating Patterns Time Limit:3000MS Memory Limit:Unknown 64bit IO Format:%lld & %llu Descr ...
- Drivers Dissatisfaction
Drivers Dissatisfaction time limit per test 4 seconds memory limit per test 256 megabytes input stan ...