Submission #50681097
Source Code Expand
#include <bits/stdc++.h> #ifdef LOCAL #include "debug.h" #else #define debug(...) #endif using int64 = long long; using uint = unsigned int; using uint64 = unsigned long long; bool ckmin(auto& a, auto b) { return b < a ? a = b, 1 : 0; } bool ckmax(auto& a, auto b) { return b > a ? a = b, 1 : 0; } using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { for (int j = 2; j * j <= a[i]; j++) { while (a[i] % (j * j) == 0) a[i] /= j * j; } } map<int, int> cnt; int n0 = 0; for (int i = 0; i < n; i++) { if (a[i] == 0) { n0++; } else { cnt[a[i]]++; } } int64 ans = 0; ans += (int64)n0 * (n0 - 1) / 2; ans += (int64)n0 * (n - n0); for (auto [k, v] : cnt) { ans += (int64)v * (v - 1) / 2; } cout << ans << '\n'; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Square Pair |
User | xindubawukong |
Language | C++ 20 (gcc 12.2) |
Score | 400 |
Code Size | 977 Byte |
Status | AC |
Exec Time | 127 ms |
Memory | 9644 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_01.txt, 00_sample_02.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_01.txt | AC | 1 ms | 3456 KiB |
00_sample_02.txt | AC | 1 ms | 3524 KiB |
01_test_01.txt | AC | 112 ms | 9644 KiB |
01_test_02.txt | AC | 14 ms | 3772 KiB |
01_test_03.txt | AC | 7 ms | 3776 KiB |
01_test_04.txt | AC | 69 ms | 6504 KiB |
01_test_05.txt | AC | 84 ms | 6948 KiB |
01_test_06.txt | AC | 99 ms | 7272 KiB |
01_test_07.txt | AC | 21 ms | 3788 KiB |
01_test_08.txt | AC | 21 ms | 3848 KiB |
01_test_09.txt | AC | 1 ms | 3416 KiB |
01_test_10.txt | AC | 1 ms | 3320 KiB |
01_test_11.txt | AC | 8 ms | 3944 KiB |
01_test_12.txt | AC | 127 ms | 7748 KiB |
01_test_13.txt | AC | 83 ms | 6720 KiB |
01_test_14.txt | AC | 11 ms | 4048 KiB |
01_test_15.txt | AC | 100 ms | 7292 KiB |