Loading...
Submission
# When Author Problem Language CPU Memory
7780 2023-04-12 01:05:59 Rakib Square Reconstruction C++ 17 287 ms 7036 kb Accepted
Test Cases
# CPU Memory Points
1 149 ms 6996 kb 1 Accepted
2 166 ms 6952 kb 1 Accepted
3 180 ms 6940 kb 1 Accepted
4 213 ms 6940 kb 1 Accepted
5 287 ms 7036 kb 1 Accepted
6 138 ms 6824 kb 1 Accepted
7 171 ms 6948 kb 1 Accepted
8 142 ms 6968 kb 1 Accepted
9 136 ms 6844 kb 1 Accepted
10 166 ms 6964 kb 1 Accepted
Source Code
  1. // @Rakibul-Islam :)
  2.  
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5.  
  6. using ll = long long;
  7. const ll INF = 1e18;
  8. const int inf = 2e9;
  9. const int mod = 1e9+7;
  10. const int N = 1e6+10;
  11. const int p = 998244353;
  12.  
  13. vector<bool> prime(N, 1);
  14. vector<int> spf(N);
  15.  
  16. void testcase(){
  17. int n;
  18. cin>>n;
  19. map<int, int> cnt;
  20.  
  21. while(n>1){
  22. int t = spf[n];
  23. n /= t;
  24. cnt[t]++;
  25. }
  26.  
  27. if(n>1)cnt[n]++;
  28. ll ans = 1;
  29. for(auto [x, y]:cnt){
  30. if(y%2==1){
  31. ans *= x;
  32. }
  33. }
  34. cout<<ans<<"\n";
  35. }
  36.  
  37. int main(){
  38. ios_base::sync_with_stdio(false);
  39. cin.tie(0);
  40. int testCase = 1;
  41. cin>>testCase;
  42.  
  43. prime[0] = prime[1] = 0;
  44. for(int i=2; i<N; i++){
  45. if(prime[i]){
  46. spf[i] = i;
  47. for(int j=i+i; j<N; j+=i){
  48. prime[j] = 0;
  49. spf[j] = i;
  50. }
  51. }
  52. }
  53.  
  54. cout<<fixed<<setprecision(20);
  55. for(int i=1;i<=testCase; i++){
  56. //cout<<"Case "<<i<<": ";
  57. testcase();
  58. }
  59. return 0;
  60. }
  61.