1019 General Palindromic Number (20 分)

#include<bits/stdc++.h>
using namespace std;

vector<int> convertNum;

void convert(long long num, int radix) {
	do {
		convertNum.push_back(num % radix);
		num /= radix;
	} while(num != 0);

}

int main() {
	long long num;
	int radix;
	cin >> num >> radix;
	convert(num, radix);

	int flag = true;
	for(int i = 0;i < convertNum.size()>>1;++i) {
		if(convertNum[i] != convertNum[convertNum.size() - 1 - i]) {
			flag = false;
			break;
		}
	}
	flag ? cout<<"Yes\n" : cout<<"No\n";
	for(int i = convertNum.size() - 1;i >= 0 ;--i)
		cout << convertNum[i] << (i == 0 ? "\n" : " ");

	return 0;
}
上一篇:PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642


下一篇:PAT 1019 General Palindromic Number