Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include "stdafx.h"
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <cmath>
- using namespace std;
- bool check_pallindrom(long number, long base);
- int main() {
- int n, temp;
- bool pallindrom(false);
- cin >> n;
- for (size_t i = 0; i < n; i++)
- {
- cin >> temp;
- for (size_t j = 2; j < temp - 2; j++)
- {
- if (check_pallindrom(temp, j)) {
- pallindrom = true;
- break;
- }
- }
- if (pallindrom)
- cout << "NO" << endl;
- else
- cout << "Yes" << endl;
- }
- return 0;
- }
- bool check_pallindrom(long number, long base) {
- vector<int> reminders;
- while (number > 0) {
- reminders.push_back(number % base);
- number /= base;
- }
- for (size_t i = 0, j = reminders.size() - 1; i < j; i++, j--)
- {
- if (reminders[i] != reminders[j])
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement