/
A.cpp
119 lines (104 loc) · 1.88 KB
/
A.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
#include<bits/stdc++.h>
/*Author - Silent Knight
Institution - Birla Institute Of Technology, Mesra
*/
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
ll modInverse(ll n,ll p)
{
ll x = n;
ll y = p-2;
ll res = 1;
x = x % p;
while (y > 0)
{
if (y & 1)
res = (res*x) % p;
y = y>>1;
x = (x*x) % p;
}
return res;
}
ll nCrModPFermat(ll n,ll r,ll p) //if mod value is prime
{
if (r == 0)
return 1;
ll fac[n+1];
fac[0] = 1;
for (ll i=1 ; i<=n; i++)
fac[i] = fac[i-1]*i%p;
return (fac[n]*modInverse(fac[r], p) % p*modInverse(fac[n-r], p) % p) % p;
}
ll nCrModP(ll n,ll r,ll p) //normal iterative solution for all values of mod
{
r = min(r,n-r);
ll c[r+1];
memset(c,0,sizeof(c));
c[0] = 1;
for(ll i=1;i<=n;i++)
{
for(ll j=min(i,r);j>0;j--)
{
c[j] = (c[j] + c[j-1])%p;
}
}
return c[r];
}
void PacalCombinations(ll size)
{
ll a[size][size];
for(ll i=0;i<size;i++)
{
for(ll j=0;j<size;j++)
a[i][j] = 0;
}
a[0][0] = 1;
for(ll i=1;i<size;i++)
{
for(ll j=0;j<=i;j++)
{
if(j == 0 || j == i)
a[i][j] = 1;
else
a[i][j] = a[i-1][j-1] + a[i-1][j];
}
}
}
ll power(ll x, ll y, ll p)
{
ll res = 1;
x = x % p;
while (y > 0)
{
if (y & 1)
res = (res*x) % p;
y = y>>1;
x = (x*x) % p;
}
return res;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;
cin>>t;
while(t--)
{
ll n;
cin>>n;
for(ll i=2;i<=40;i++)
{
ll temp = (1<<i)-1;
if(n%temp == 0)
{
cout<<(n/temp);
break;
}
}
cout<<"\n";
}
return 0;
}