forked from 18-RAJAT/ONLINE-JUDGE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
A_Odd_Divisor.cpp
332 lines (266 loc) · 8.95 KB
/
A_Odd_Divisor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
/*
* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
* Example:- $ g++ -std=c++11 c++Template.cpp
*
* Author : Rajat Joshi
* Handle: 18-RAJAT
*
*/
// Those who cannot remember the past are condemned to repeat it
/******** All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include<bits/stdc++.h>
using namespace std;
/******* All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
const double pi=acos(-1.0);
#define ll long long
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
// ----------------------<MATH>---------------------------
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
int add(int a, int b, int c = MOD){int res=a+b;
return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c = MOD){int res;
if(abs(a-b)<c)res=a-b;else res=(a-b)%c;
return(res<0?res+c:res);}
int mul(int a, int b, int c = MOD){ll res=(ll)a*b;
return(res>=c?res%c:res);}
int muln(int a, int b, int c = MOD){ll res=(ll)a*b;}
// // Permutation and Combination
// int ncr(int n,int r,int c = MOD){
// return mul(mul(ifact[r],ifact[n-r],c),fact[n],c);
// }
// ----------------------</MATH>--------------------------
// ----------------------</BITWISE>--------------------------
/* a=target variable, b=bit number to act upon 0-n */
#define BIT_SET(a,b) ((a) |= (1ULL<<(b)))
#define BIT_CLEAR(a,b) ((a) &= ~(1ULL<<(b)))
#define BIT_FLIP(a,b) ((a) ^= (1ULL<<(b)))
// '!!' to make sure this returns 0 or 1
#define BIT_CHECK(a,b) (!!((a) & (1ULL<<(b))))
#define BITMASK_SET(x, mask) ((x) |= (mask))
#define BITMASK_CLEAR(x, mask) ((x) &= (~(mask)))
#define BITMASK_FLIP(x, mask) ((x) ^= (mask))
#define BITMASK_CHECK_ALL(x, mask) (!(~(x) & (mask)))
#define BITMASK_CHECK_ANY(x, mask) ((x) & (mask))
// ----------------------</BITWISE END>--------------------------
/****************** Prime Generator **********************/
const int N=1e7+10; int prime[20000010];
bool isprime[N]; int nprime;
template <typename T> void Sieve(T a)
{nprime = 0;memset(isprime,true,sizeof(isprime));
isprime[1]=false;for(int i=2;i<N;i++){
if(isprime[i]){prime[nprime++]=i;for(int j=2;i*j<N;j++)
isprime[i*j]=false;}}}
template <typename T> inline T PrimeFactors(T n)
{ll cnt=0,sum=1;for(int i=0; prime[i]*prime[i]<=n
and i<nprime;i++){cnt=0;while(n%prime[i]==0)
{cnt++;n/=prime[i];}sum*=(cnt+1);}
if(n>1)sum*=2;return sum;}
/**************** Prime Generator End ********************/
/****************** Geometry *****************/
template <typename T> inline T PointDistanceHorVer(T x1,T y1,T x2, T y2)
{return abs(x1-x2)+abs(y1-y2);}
template <typename T> inline T PointDistanceDiagonally(T x1,T y1,T x2, T y2)
{return sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));}
template <typename T> inline T PointDistanceMinimum(T x1,T y1,T x2, T y2)
{ T tmp1=abs(x1-x2); T tmp2=abs(y1-y2); T tmp3=abs(tmp1-tmp2);
T tmp4=min(tmp1, tmp2); return tmp3+tmp4; }
template <typename T> inline T PointDistance3D(T x1,T y1,T z1,T x2,T y2,T z2)
{return sqrt(square(x2-x1)+square(y2-y1)+square(z2-z1));}
template <typename T> inline T Cube(T a){return a*a*a;}
template <typename T> inline T RectengularPrism(T a,T b,T c)
{return a*b*c;}
template <typename T> inline T Pyramid(T base, T height)
{return (1/3)*base*height;}
template <typename T> inline T Ellipsoid(T r1,T r2,T r3)
{return (4/3)*PI*r1*r2*r3;}
template <typename T> inline T IrregualarPrism(T base, T height)
{return base*height;}
template <typename T> inline T Sphere(T radius)
{ return (4/3)*PI*radius*radius*radius;}
template <typename T> inline T CylinderB(T base, T height)
{return base*height;} // base and height
template <typename T> inline T CylinderR(T radius, T height)
{return PI*radius*radius*height;} // radius and height
template <typename T> inline T Cone (T radius,T base, T height)
{return (1/3)*PI*radius*radius*height;}
/****************** Geometry end *****************/
/****** Template of some basic operations *****/
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
/**********************************************/
/****** Template of Fast I/O Methods *********/
template <typename T> inline void write(T x)
{
int i = 20;
char buf[21];
// buf[10] = 0;
buf[20] = '\n';
do
{
buf[--i] = x % 10 + '0';
x/= 10;
}while(x);
do
{
putchar(buf[i]);
} while (buf[i++] != '\n');
}
template <typename T> inline T readInt()
{
T n=0,s=1;
char p=getchar();
if(p=='-')
s=-1;
while((p<'0'||p>'9')&&p!=EOF&&p!='-')
p=getchar();
if(p=='-')
s=-1,p=getchar();
while(p>='0'&&p<='9') {
n = (n<< 3) + (n<< 1) + (p - '0');
p=getchar();
}
return n*s;
}
/************************************/
/******* Debugging Class Template *******/
#define DEBUG
#ifdef DEBUG
#define debug(args...) (Debugger()) , args
class Debugger
{
public:
Debugger(const std::string& _separator = " - ") :
first(true), separator(_separator){}
template<typename ObjectType> Debugger& operator , (const ObjectType& v)
{
if(!first)
std:cerr << separator;
std::cerr << v;
first = false;
return *this;
}
~Debugger() { std:cerr << endl;}
private:
bool first;
std::string separator;
};
#else
#define debug(args...) // Just strip off all debug tokens
#endif
/**************************************/
/******** User-defined Function *******/
/**************************************/
/********** Main() function **********/
// void Fpresuf(int pre[],int a[],int suf[],int n)
// {
// pre[0]=a[0];
// for(int i=1;i<n;++i)
// pre[i]=__gcd(pre[i-1],a[i]);
// suf[n-1]=a[n-1];
// for(int i=n-2;i>=0;--i)
// suf[i]==__gcd(suf[i+1],a[i]);
// }
// int gcdR(int l,int r,int pre[],int suf[],int n)
// {
// if(l==0)return suf[r+1];
// if(r==n-1)return pre[l-1];
// return __gcd(pre[l-1],suf[r+1]);
// }
vector<vector<int>> threeSum(vector<int>& nums) {
set<vector<int>> s;//to get unique triplets
sort(nums.begin(),nums.end());
int n=nums.size();
vector<int> temp;
temp.resize(3);
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)
{
if(binary_search(nums.begin()+j+1,nums.end(),-nums[i]-nums[j])){
temp[0]=nums[i],temp[1]=nums[j],temp[2]=-nums[i]-nums[j];
sort(temp.begin(),temp.end());
//to get triplet in an order, will be easy to check if
//duplicate exists or not
s.insert(temp);
}
}
vector<vector<int>> ans;
for(auto triplet: s)
ans.push_back(triplet);
return ans;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin); //file input.txt is opened in reading mode i.e "r"
freopen("output.txt","w",stdout); //file output.txt is opened in writing mode i.e "w"
#endif
int tc=1;
tc = read(int);
while(tc--)
{
long long n;cin>>n;
while(n%2 ==0){n=n/2;}
if(n==1){cout<<"NO"<<"\n";}
else{cout<<"YES"<<"\n";}
}
return 0;
}