【PAT甲级】1019 General Palindromic Number (20 分)
题意:
输入两个正整数n和b(n<=1e9,2<=b<=1e9),分别表示数字的大小和进制大小,求在b进制下n是否是一个回文串,输出“Yes”or“No”,并将数字n在b进制下打印出来,用空格间隔开每一位数字。
AAAAAccepted code:
#include<bits/stdc++.h>
using namespace std;
int a[];
int main(){
int n,b;
cin>>n>>b;
int cnt=;
while(n){
a[++cnt]=n%b;
n/=b;
}
int flag=;
for(int i=;i<=cnt/;++i)
if(a[i]!=a[cnt-i+])
flag=;
if(!flag)
cout<<"Yes"<<"\n";
else
cout<<"No"<<"\n";
for(int i=cnt;i>;--i)
cout<<a[i]<<" ";
cout<<a[];
return ;
}
【PAT甲级】1019 General Palindromic Number (20 分)的更多相关文章
- 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 ...
- 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 甲级 1019 General Palindromic Number (进制转换,vector运用,一开始2个测试点没过)
1019 General Palindromic Number (20 分) A number that will be the same when it is written forwards ...
- PAT 甲级 1019 General Palindromic Number(简单题)
1019. General Palindromic Number (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
- PAT 甲级 1019 General Palindromic Number(20)(测试点分析)
1019 General Palindromic Number(20 分) A number that will be the same when it is written forwards or ...
- PAT甲级——1019 General Palindromic Number
A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...
- 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 甲级 1019 General Palindromic Number
https://pintia.cn/problem-sets/994805342720868352/problems/994805487143337984 A number that will be ...
- 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 ...
随机推荐
- C语言中调用运行python程序
C语言中调用运行python程序: Python代码如下: 创建test.py. #!/usr/bin/python3 #test.py import sys x = ]) print x*x 注意: ...
- git查漏补缺
1. commit提交注释规范 2. commit 注释没写完或写错了,在不用删除这条commit的情况下,如何更正注释信息 git commit -m '1' git commit --amend ...
- P1030 求先序排列 (一个非常棒的写法)
理论正确就是真正的正确,误... 就是找嘛,找到每一个对应字符,然后对应的左右子树的区间,然后就可以了. #include <bits/stdc++.h> using namespace ...
- Python学习(六)—— 函数、全局变量与局部变量
函数 函数的定义 def test(x): "The function definition" x += 1 return x def:定义函数的关键字 test:函数名 ():内 ...
- jdk 9 10 11 12 13 新特性
jdk 9 新特性 1.集合加强 jdk9 为所有集合(List/Set/Map)都增加了 of 和 copyOf 方法,用来创建不可变集合,即一旦创建就无法再执行添加.删除.替换.排序等操作,否则将 ...
- SpringBoot-自动装载
1,SpringBoot里面有内置的tomcat容器. 2,SpringBoot是基于已有的东西创建的新的东西.核心:(AutoConfiguration)自动装载,Starter,Actuator, ...
- Android学习02
今天学了ScrollView&HorizontalScrollView和WebView 一.ScrollView(垂直滚动),HorizontalScrollView(水平滚动) Scroll ...
- redis (一) --- 基本使用
概述 redis是基于key-value 我们所说的数据类型实际是 key-value 中的 value .文章主要介绍的是redis 几个重要的数据类型的使用. 简单使用 //keys patter ...
- java 限制每隔15分钟才允许执行一次程序
由于公司订餐平台,有个用户催单业务,每当用户点击催单按钮时,商家就会收到消息提示,如果用户频繁的发起催单请求,这样商家就会不停的收到消息提醒,所以想限制用户至少每隔15分钟才可以催单一次 我采取了以下 ...
- 基于MHA的MYSQL高可用方案
一.MHA 简介 MHA (Master High Availability )目前在 MySQL 高可用方面是一个相对成熟的解决方案,它由日本 DeNA 公司的 youshimaton 员工(现就职 ...