Loading...
Submission
Id When Author Problem Language CPU Memory Verdict
16901 2024-04-22 19:40:44 punter Square Reconstruction C++ 17 78 ms 3432 kb Runtime Error - 4
Test Cases
CPU Memory Verdict
1 2 ms 3432 kb Accepted
2 1 ms 3428 kb Accepted
3 78 ms 3308 kb Accepted
4 1 ms 3216 kb Runtime Error
5 - - Skipped
6 - - Skipped
7 - - Skipped
8 - - Skipped
9 - - Skipped
10 - - Skipped
Source Code
program.cpp
Download
  1. /**
  2. * Author : Arif Ahmad
  3. * Date :
  4. * Algo :
  5. * Difficulty:
  6. */
  7.  
  8. #include <bits/stdc++.h>
  9. using namespace std;
  10.  
  11. #define INF_MAX 2147483647
  12. #define INF_MIN -2147483648
  13. #define INF (1 << 30)
  14. #define EPS 1e-9
  15. #define PI acos(-1.0)
  16. #define N 11234
  17. #define MOD 10000000007
  18. #define sz(x) (int)(x).size()
  19. #define all(x) (x).begin(), (x).end()
  20. #define pb push_back
  21. #define mp make_pair
  22. #define ms(x, a) memset((x), (a), sizeof(x))
  23. #define F first
  24. #define S second
  25. #define rep(i,a,b) for(int i=(a); i<(b); ++i)
  26. #define repC(i,x) for(size_t i=0; i<x.size(); ++i)
  27. #define repIT(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
  28. #define nn '\n'
  29. #define trace(x) cerr << #x << " = " << x << '\n';
  30. #define trace2(x,y) cerr << #x << "=" << x << "\t" << #y << "=" << y << '\n';
  31.  
  32. typedef long long LL;
  33. typedef pair<int,int> pii;
  34. typedef vector<int> vi;
  35. typedef vector<string> vs;
  36. typedef vector<char> vc;
  37. typedef vector<bool> vb;
  38. typedef vector< pii > vii;
  39. typedef map<string,int> msi;
  40. typedef map<int,int> mii;
  41. typedef map<char,int> mci;
  42. typedef map<int,string> mis;
  43.  
  44. template<class T> T Abs(T x) {return x>0 ? x : -x;}
  45. template<class T> T Max(T a, T b) {return a>b ? a : b;}
  46. template<class T> T Min(T a, T b) {return a<b ? a : b;}
  47. template<class T> T gcd(T a, T b) {return (b ? gcd(b,a%b) : a);}
  48. bool isVowel(char ch){ch=tolower(ch);return(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u');}
  49.  
  50. //int dx[4] = {-1, 0, 0, 1};
  51. //int dy[4] = {0, -1, 1, 0};
  52. //int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
  53. //int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
  54.  
  55. vi factors;
  56.  
  57. void prime_factorize(int n)
  58. {
  59. factors.clear();
  60. factors.resize(N, 0);
  61.  
  62. for(int i = 2; i * i <= n; i++) {
  63. while(n % i == 0) {
  64. factors[i]++;
  65. n /= i;
  66. }
  67. }
  68. if(n > 1) {
  69. factors[n]++;
  70. }
  71. }
  72.  
  73. int main()
  74. {
  75. ios_base :: sync_with_stdio(0);
  76. cin.tie(0);
  77.  
  78. // #ifndef ONLINE_JUDGE
  79. // freopen("in.txt", "r", stdin);
  80. // #endif
  81.  
  82. int i, j, k, n, m, tc;
  83.  
  84. cin >> tc;
  85. while(tc--) {
  86. cin >> n;
  87.  
  88. prime_factorize(n);
  89.  
  90. int ans = 1;
  91. bool is_prime = true;
  92. for(i = 2; i < N; i++) {
  93. if(factors[i]) {
  94. //trace2(factors[i], i);
  95. is_prime = false;
  96. }
  97. if(factors[i] > 0 && factors[i] % 2 == 1) {
  98.  
  99. ans *= i;
  100. }
  101. }
  102.  
  103. if(ans == 1 and n > 1 and is_prime) ans = n;
  104. cout << ans << nn;
  105. }
  106.  
  107. return 0;
  108. }
  109.  
  110. /*
  111.  
  112. */
  113.