-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB_Duff_in_Love.cpp
More file actions
189 lines (167 loc) · 4.48 KB
/
Copy pathB_Duff_in_Love.cpp
File metadata and controls
189 lines (167 loc) · 4.48 KB
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
#include <stack>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <functional>
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define infinity 999999999999999999
#define float long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define MOD_DEFINE const int MOD = 1e9 + 7;
#define And &&
#define Or ||
#define endl '\n'
#define space " "
#define int long long
#define pii pair<int, int>
#define vi vector<int>
#define pb(n) push_back(n)
#define mii map<int, int>
#define umii unordered map<int, int>
#define test_cases_loop int t; cin >> t; while(t--)
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define loop(var, initial, final) for(int var=initial; var < final; var++)
using namespace std;
template<typename T>
void print(array<T,2> &arr);
template<typename T>
void print(vector<T> &v);
template<typename T>
void print(deque<T> &v);
template<typename T>
T _gcd(T a, T b);
template<typename T>
vector<T> sieve(T n);
template<typename T>
T power(T x, T y, int p = LLONG_MAX);
int nxt();
// Returns n^(-1) mod p
template<typename T>
T modInverse(T n, T p);
int gcd(vector<int> &diff);
bool isPowerof2(int x);
vector<int> divisors(int n){
vector<int> ans;
for(int i = 2;i<=sqrt(n);i++){
if(n % i ==0){
ans.pb(i);
if(n/i != i) ans.pb(n/i);
}
}
ans.pb(1);
return ans;
}
// ----------------------------------------------------------------------------------------------------------- //
// ----------------------------------------------------------------------------------------------------------- //
// ----------------------------------------------------------------------------------------------------------- //
// ----------------------------------------------------------------------------------------------------------- //
// ----------------------------------------------------------------------------------------------------------- //
int32_t main(){
FIO
int n;
cin>>n;
// vi divi = divisors(n);
loop(i, 2, (int)sqrt(n) + 1){
while (n % (i*i) == 0){
// cout<<n<<space<<i<<endl;
n/=i;
}
if (n==1) break;
}
cout<<n<<endl;
return 0;
}
// ----------------------------------------------------------------------------------------------------------- //
// ----------------------------------------------------------------------------------------------------------- //
// ----------------------------------------------------------------------------------------------------------- //
// ----------------------------------------------------------------------------------------------------------- //
// ----------------------------------------------------------------------------------------------------------- //
template<typename T>
T power(T x, T y, int p) {
T res = 1; // Initialize result
x = x % p; // Update x if it is more than or
// equal to p
// cout <<"x= "<< x << endl;
while (y > 0)
{
// If y is odd, multiply x with result
if (y & 1)
res = (res*x) % p;
// y must be even now
y = y>>1; // y = y/2
x = (x*x) % p;
}
// cout << "res" << res << endl;
return res;
}
template<typename T>
vector<T> sieve(T n){
vector<int> prime(n+1, 1);
for(int i = 2; i*i<=n; i++){
if(prime[i]){
for(int j = 2; j*i<=n; j++){
prime[i*j] = 0;
}
}
}
vector<T> ans;
for(int i = 2; i<=n;i++){
if(prime[i]) ans.pb(i);
}
return prime;
}
template<typename T>
T _gcd(T a, T b){
T temp1 = max(a,b), temp2 = min(a,b);
a = temp1, b = temp2;
if(a == 0) return b;
if(b == 0) return a;
if(a%b ==0) return b;
return _gcd(b, a%b);
}
template<typename T>
void print(array<T,2> &arr){
cout << arr[0] << " " << arr[1] << endl;
}
template<typename T>
void print(vector<T> &v){
for(T x: v) cout << x << " ";
cout << endl;
}
template<typename T>
T modInverse(T n, T p){
return power(n, p-2, p)%p;
}
template<typename T>
void print(deque<T> &v){
for(auto x: v) cout << x << " ";
cout << endl;
}
int nxt(){
int x;
cin >> x;
return x;
}
bool isPowerof2(int x){
return !(x && (x & (x-1)));
}