Loading...
Submission
# When Author Problem Language CPU Memory
20636 2024-05-23 14:43:46 sumaiyaamin Square Reconstruction C++ 17 6 ms 3388 kb Accepted
Test Cases
# CPU Memory Points
1 2 ms 3344 kb 1 Accepted
2 1 ms 3268 kb 1 Accepted
3 4 ms 3308 kb 1 Accepted
4 5 ms 3388 kb 1 Accepted
5 5 ms 3312 kb 1 Accepted
6 4 ms 3216 kb 1 Accepted
7 6 ms 3348 kb 1 Accepted
8 6 ms 3348 kb 1 Accepted
9 3 ms 3308 kb 1 Accepted
10 3 ms 3268 kb 1 Accepted
Source Code
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. long long minimum_m(long long n) {
  6. long long m = 1;
  7. for (long long i = 2; i * i <= n; i++) {
  8. if (n % i == 0) {
  9. int count = 0;
  10. while (n % i == 0) {
  11. n /= i;
  12. count++;
  13. }
  14. if (count % 2 != 0) { // If the count of this prime factor is odd
  15. m *= i; // Multiply m by this prime to make the count even
  16. }
  17. }
  18. }
  19. if (n > 1) { // If there's any prime factor larger than sqrt(n)
  20. m *= n; // It will have an odd count (1), so multiply m by this prime
  21. }
  22. return m;
  23. }
  24.  
  25. int main() {
  26. int t;
  27. cin >> t;
  28. while (t--) {
  29. long long n;
  30. cin >> n;
  31. cout << minimum_m(n) << endl;
  32. }
  33. return 0;
  34. }