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 ...
随机推荐
- Java 面试题 三 <JavaWeb应用调优线程池 JVM原理及调优>
1.Java Web应用调优线程池 不论你是否关注,Java Web应用都或多或少的使用了线程池来处理请求.线程池的实现细节可能会被忽视,但是有关于线程池的使用和调优迟早是需要了解的.本文由浅入深,介 ...
- P1359 租用游艇 && P3905 道路重建 ------Floyd算法
P1359 租用游艇 原题链接https://www.luogu.org/problemnew/show/P1359 P3905 道路重建 原题链接https://www.luogu.org/ ...
- Python实用黑科技——解包元素(1)
需求: 很多时候手上已经有了一个具有n个元素的列表或者元组,你打算把这些元素单独取出来(解包)放入n个变量组成的集合(这里的集合和Python自己的set不同)中. 方法: 显然,最好的办法就是直接用 ...
- [pytorch] PyTorch Hook
PyTorch Hook¶ 为什么要引入hook? -> hook可以做什么? 都有哪些hook? 如何使用hook? 1. 为什么引入hook?¶ 参考:Pytorch中autogra ...
- JavaWeb_(Mybatis框架)JDBC操作数据库和Mybatis框架操作数据库区别_一
系列博文: JavaWeb_(Mybatis框架)JDBC操作数据库和Mybatis框架操作数据库区别_一 传送门 JavaWeb_(Mybatis框架)使用Mybatis对表进行增.删.改.查操作_ ...
- docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"ping\": executable file not found in $PATH": unknown.
docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting cont ...
- 【Android】【踩坑日记】RecyclerView获取子View的正确姿势
开发过程中发现RecyclerView.getChildAt(position)为空的情况,但是明明这个position却没有越界. 解决办法:用recycler.getLayoutManager() ...
- spring MVC 拦截有几种实现方式
spring MVC 拦截有几种实现方式 实现HandelInterceptor接口方式 继承HandelInterceptor 的方式.一般有这两种方式 spring 如何走单元测式 ...
- tensorflow feeddict问题unhashable type: 'numpy.ndarray'
https://stackoverflow.com/a/49134587 求argmax.加newaxis.转变data类型时尽量用tf自带的函数: tf.argmax.[tf.newaxis, :] ...
- asp.net webAPI
Get: 1.Get参数传递的本质是url字符串拼接:2.url字符串长度受限制:3.Get参数传递在Http请求头部传递,而不支持Request-Body传递:4.Get类型的方法支持参数为基本类型 ...