A1019
Description:
给出数字和基数,判断该数在该基数下表示是否为回文串;
我总有一种把简单的题写的巨繁琐的魔力…
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
using namespace std;
long long n;
int b;
vector<long long>quan;
vector<int>ans;
int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif // ONLINE_JUDGE
scanf("%lld%d", &n, &b);
quan.push_back(1);
long long now = 1;int in = 1;
while(*(quan.end()-1) <= n){
quan.push_back(*(quan.end()-1)*b);
}
ans.resize(quan.size()-1);
in = quan.size()-1;
while(n != 0){
ans[--in] = n - n/b*b;
n = n/b;
}
int i;
for(i = 0; i < ans.size()/2; i++){
if(ans[i] != ans[ans.size()-1-i]){
printf("No\n");
break;
}
}
if(i >= ans.size()/2) printf("Yes\n");
for(i = 0; i < ans.size(); i++){
if(i != 0) printf(" ");
printf("%d", ans[i]);
}
return 0;
}