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
// @Rakibul-Islam :) #include <bits/stdc++.h> using namespace std; using ll = long long; const ll INF = 1e18; const int inf = 2e9; const int mod = 1e9+7; const int N = 1e6+10; const int p = 998244353; vector<bool> prime(N, 1); vector<int> spf(N); void testcase(){ int n; cin>>n; map<int, int> cnt; while(n>1){ int t = spf[n]; n /= t; cnt[t]++; } if(n>1)cnt[n]++; ll ans = 1; for(auto [x, y]:cnt){ if(y%2==1){ ans *= x; } } cout<<ans<<"\n"; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int testCase = 1; cin>>testCase; prime[0] = prime[1] = 0; for(int i=2; i<N; i++){ if(prime[i]){ spf[i] = i; for(int j=i+i; j<N; j+=i){ prime[j] = 0; spf[j] = i; } } } cout<<fixed<<setprecision(20); for(int i=1;i<=testCase; i++){ //cout<<"Case "<<i<<": "; testcase(); } return 0; }