Loading...
Submission
Id When Author Problem Language CPU Memory Verdict
16892 2024-04-21 14:35:25 punter Square Reconstruction C++ 17 7 ms 3368 kb Wrong Answer - 3
Test Cases
CPU Memory Verdict
1 2 ms 3248 kb Accepted
2 1 ms 3368 kb Accepted
3 7 ms 3344 kb Wrong Answer
4 - - Skipped
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 112345
  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(1000, 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.  
  79. int i, j, k, n, m, tc;
  80.  
  81. cin >> tc;
  82. while(tc--) {
  83. cin >> n;
  84.  
  85. prime_factorize(n);
  86.  
  87. int ans = 1;
  88. for(i = 2; i < 1000; i++) {
  89. if(factors[i] > 0 && factors[i] % 2 == 1) {
  90. ans *= i;
  91. }
  92. }
  93.  
  94. cout << ans << nn;
  95. }
  96.  
  97. return 0;
  98. }
  99.