Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.math.BigInteger;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.List;
- import java.util.Scanner;
- public class Main {
- public static boolean isPal(Long a) {
- String a3 = Long.toString(a);
- String a2 = new StringBuffer(a3).reverse().toString();
- if (a3.equals(a2)) return true;
- else return false;
- }
- public static Long transform(Long from, int radix) {
- String s = "";
- while (from != 0) {
- s = (from % radix) + s;
- from /= radix;
- }
- return Long.parseLong(s);
- }
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int col = sc.nextInt();
- Long[] mas = new Long[col];
- for (int i = 0; i < col; i++) {
- mas[i] = sc.nextLong();
- }
- for (int i = 0; i < mas.length; i++) {
- Boolean t = false;
- // System.out.println(mas[i]);
- for (int j = 2; j <= mas[i] - 2; j++) {
- // System.out.println(transform(mas[i],j)+" " +j);
- if (isPal(transform(mas[i], j))) {
- t = true;
- break;
- }
- }
- if (t) System.out.println("NO");
- else System.out.println("YES");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement