Submission
Id | When | Author | Problem | Language | CPU | Memory | Verdict |
---|---|---|---|---|---|---|---|
16902 | 2024-04-22 19:52:20 | punter | Square Reconstruction | C++ 17 | 4 ms | 3480 kb | Accepted |
Test Cases
CPU | Memory | Verdict | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
1 | 2 ms | 3436 kb | Accepted | ||||||||
2 | 1 ms | 3472 kb | Accepted | ||||||||
3 | 3 ms | 3356 kb | Accepted | ||||||||
4 | 3 ms | 3400 kb | Accepted | ||||||||
5 | 3 ms | 3416 kb | Accepted | ||||||||
6 | 4 ms | 3476 kb | Accepted | ||||||||
7 | 3 ms | 3416 kb | Accepted | ||||||||
8 | 3 ms | 3320 kb | Accepted | ||||||||
9 | 2 ms | 3480 kb | Accepted | ||||||||
10 | 2 ms | 3404 kb | Accepted | ||||||||
Source Code
program.cpp
/** * Author : Arif Ahmad * Date : * Algo : * Difficulty: */ #include <bits/stdc++.h> using namespace std; #define INF_MAX 2147483647 #define INF_MIN -2147483648 #define INF (1 << 30) #define EPS 1e-9 #define PI acos(-1.0) #define N 11234 #define MOD 10000000007 #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #define pb push_back #define mp make_pair #define ms(x, a) memset((x), (a), sizeof(x)) #define F first #define S second #define rep(i,a,b) for(int i=(a); i<(b); ++i) #define repC(i,x) for(size_t i=0; i<x.size(); ++i) #define repIT(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define nn '\n' #define trace(x) cerr << #x << " = " << x << '\n'; #define trace2(x,y) cerr << #x << "=" << x << "\t" << #y << "=" << y << '\n'; typedef long long LL; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<string> vs; typedef vector<char> vc; typedef vector<bool> vb; typedef vector< pii > vii; typedef map<string,int> msi; typedef map<int,int> mii; typedef map<char,int> mci; typedef map<int,string> mis; template<class T> T Abs(T x) {return x>0 ? x : -x;} template<class T> T Max(T a, T b) {return a>b ? a : b;} template<class T> T Min(T a, T b) {return a<b ? a : b;} template<class T> T gcd(T a, T b) {return (b ? gcd(b,a%b) : a);} bool isVowel(char ch){ch=tolower(ch);return(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u');} //int dx[4] = {-1, 0, 0, 1}; //int dy[4] = {0, -1, 1, 0}; //int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; //int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; bool num[N]; int primes[10000]; // there are 9592 primes between 1 and 100000 map<int, int> factors; int maxSize; void sieve() { int i,j,k; memset(num, true, sizeof(num)); num[0] = num[1] = false; for(i=4; i<N; i+=2) num[i] = false; for(i=3,j=sqrt(N)+1; i<j; i+=2) { if(num[i] == true) { k = i; while(k+i < N) { k += i; num[k] = false; } } } } void store() { int total = 0; for(int i=2; i<N; i++) if(num[i]) primes[total++] = i; } void primeFactorize(int n) { int i, sqrtN = (int) sqrt(n); for(i=0; primes[i]<=sqrtN; i++) if(n%primes[i] == 0) { while(n%primes[i] == 0) { n /= primes[i]; factors[primes[i]]++; } } if(n > 1) factors[n]++; } int main() { ios_base :: sync_with_stdio(0); cin.tie(0); // #ifndef ONLINE_JUDGE // freopen("in.txt", "r", stdin); // #endif int i, j, k, n, m, tc; sieve(); store(); cin >> tc; while(tc--) { cin >> n; factors.clear(); primeFactorize(n); int ans = 1; bool is_prime = true; for(auto [k,v]: factors) { if(v % 2 == 1) { ans *= k; } } // if(ans == 1 and n > 1 and is_prime) ans = n; cout << ans << nn; } return 0; } /* */