PAT A1019 General Palindromic Number (20 分)
2024-10-06 20:47:11
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;
}
最新文章
- Web:AJAX的详解
- HDU 2594 Simpsons’ Hidden Talents(辛普森一家的潜在天赋)
- 2016 - 1- 21 - RunLoop使用(2016-1-24修改一次)&;(2016 - 1 - 24 再次修改)
- easyUI之datebox
- poj 2828 Buy Tickets (线段树)
- DeDe缩略图路径的修改
- 剑指offer 27二叉搜索树与双向链表
- BZOJ 2242: [SDOI2011]计算器( 快速幂 + 扩展欧几里德 + BSGS )
- 给一个非常长的字符串str 另一个字符集比方{a,b,c} 找出str 里包括{a,b,c}的最短子串。要求O(n)
- zoj2760(最大流)
- Oracle SQL Lesson (11) - 创建其他数据库对象(试图/序列/索引/同义词)
- hihoCoder #1094 : Lost in the City(枚举,微软苏州校招笔试 12月27日 )
- Java学习网站大全
- Kube-DNS搭建(1.4版本)
- 中间件RabbitMQ之运维篇
- 【题解】Luogu P3901 数列找不同
- [leetcode]122. Best Time to Buy and Sell Stock II 最佳炒股时机之二
- Python爬虫项目--爬取自如网房源信息
- pycharm 光标快速移动到括号外或行尾
- [Algorithm] Deferred Acceptance Algorithm