PAT A1019 General Palindromic Number (20 分)
AC代码
#include <cstdio>
const int max_n = 1000;
long long ans[max_n];
int num = 0;
void change(long long a, long long d) {
do {
ans[num++] = a % d;
a /= d;
} while(a != 0);
}
int main() {
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif // ONLINE_JUDGE}
long long a, d;
scanf("%lld %lld", &a, &d);
change(a, d);
bool flag = 1;
for(int i = 0; i < num - 1- i; i++) {
if(ans[i] != ans[num - 1 - i]) flag = false;
}
if(flag == true) printf("Yes\n");
else if(flag == false) printf("No\n");
for(int i = num - 1; i >= 0; i--) {
if(i != num - 1) printf(" ");
printf("%d", ans[i]);
}
return 0;
}
PAT A1019 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 A1019 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 ...
- 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] A1019 General Palindromic Number
[题目] https://pintia.cn/problem-sets/994805342720868352/problems/994805487143337984 题目大意:给定一个N和b,求N在b ...
- 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(n<=1e9,2<=b<=1e9),分别表示数字的大小和进制大小,求在b进制下n是否是一个回文串,输出“Yes”or“No”,并将数字n在b进制下打印出 ...
- PAT 1019 General Palindromic Number[简单]
1019 General Palindromic Number (20)(20 分) A number that will be the same when it is written forward ...
- pat1019. General Palindromic Number (20)
1019. General Palindromic Number (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
随机推荐
- 在Idea中 的terminal 使用 git
参考该博客内容 http://blog.csdn.net/qq_28867949/article/details/73012300
- codeforces405D
Toy Sum CodeForces - 405D Little Chris is very keen on his toy blocks. His teacher, however, wants C ...
- LIUNX 安装 nginx
安装依赖 yum install gcc yum install pcre-devel yum install zlib zlib-devel yum install openssl openssl- ...
- IDEA2019.1.3的安装和破解
上一篇文章我有写过我会尝试安装IDEA(这玩意儿收费啊!),倘若尝试成功以后都会用它编译,很幸运,我安装成功了,所以今天这篇文章我来写安装和破解方法. IDEA界面: 首先我们访问官方网站:htt ...
- 使用fui(Find Unused Imports)扫描工程中不用的类
为了给APP提速,需要定期清理不用的类 fui(Find Unused Imports)是开源项目能很好的分析出不再使用的类,准确率非常高,唯一的问题是它处理不了动态库和静态库里提供的类,也处理不了C ...
- 获取当前页面的webview ID
代码: A页面 <script type="text/javascript"> var ws = null; mui.plusReady(function(){ ws ...
- 外网访问内网的FTP服务器
转自 外网访问内网的FTP服务器 首先感谢作者给出的总结,原文是介绍Serv-U的,我针对FileZilla Server进行了稍微修改,仅看操作可直接跳到分割线后第3部分. 1. 背景简介最近研究如 ...
- decimal模块 --数字的精度、保留小数位数、取整问题
开始之前需要注意一点是:精度值为数字的总位数,如:1.23, 精度值为3: 0.123,精度值也为3 1.更改默认精度值后,直接进行计算即可保留对应精度值 from decimal import ge ...
- Rancher Server部署方式及Rancher HA环境部署
类似Rancher这种的容器管理和编排工具,它可以很快地让每个组织获得高效的弹性集群管理能力.当前技术世界的发展形势就是让开发人员从繁琐的应用配置和管理中解放出来,使用容器镜像来处理复杂的程序运行依赖 ...
- Java 泛型,你了解类型擦除吗?
泛型,一个孤独的守门者. 大家可能会有疑问,我为什么叫做泛型是一个守门者.这其实是我个人的看法而已,我的意思是说泛型没有其看起来那么深不可测,它并不神秘与神奇.泛型是 Java 中一个很小巧的概念,但 ...