Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- --┬-- | | --┬-- | |
- | |\ | | | |
- | | \ | | -----> | |
- | | \ | | | |
- | | \ | | | |
- --┴-- | \| | └---- └----
- */
- // #define pragma
- #ifdef pragma
- #pragma GCC optimize("Ofast")
- #pragma GCC optimize("no-stack-protector")
- #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
- #pragma GCC optimize("unroll-loops")
- #pragma GCC diagnostic ignored "-Wunused-result"
- #endif // pragma
- #include<bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- #define ll long long
- #define all(x) begin(x), end(x)
- #define pb push_back
- #define x first
- #define y second
- #define int long long
- #define zero(x) memset(x, 0, sizeof(x))
- using namespace std;
- using namespace __gnu_pbds;
- typedef vector<int> vi;
- typedef vector<bool> vb;
- typedef pair<int, int> pii;
- typedef long double ld;
- typedef vector<vi> matrix;
- typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
- const int INF = 1e9 + 7;
- const int MAXN = 1e6 + 8;
- const ld EPS = 1e-9;
- const ld PI = atan2(0, -1);
- void seriy() {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- // cout << fixed << setprecision(7);
- // cerr << fixed << setprecision(7);
- #if 0
- freopen("input", "r", stdin);
- freopen("output", "w", stdout);
- #endif
- }
- bool tr(int n, int a) {
- vi s;
- while(n > 0) {
- s.pb(n % a);
- n /= a;
- }
- bool f = 0;
- for(int i = 0; i < s.size() / 2; i++) {
- if(s[i] != s[s.size() - i - 1]) {
- f = 1;
- }
- }
- return !f;
- }
- signed main() {
- seriy();
- int t;
- cin >> t;
- while(t--) {
- int n;
- cin >> n;
- bool cur = 0;
- for(int i = 2; i < n - 1; i++) {
- cur = cur | tr(n, i);
- }
- cout << ((cur) ? "NO\n" : "YES\n");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment