Submission #847682
Source Code Expand
Copy
#include<bits/stdc++.h> using namespace std; #define MAX 100002 int n; bool use[MAX]; vector<long long int> pr; #include<unordered_map> unordered_map<long long int, long long int> mp; unordered_map<long long int, int> mp2; unordered_map<long long int, int> mpp; int main(){ for (int i = 2; i < 100000; i++){ if (use[i] == false){ pr.push_back(i); for (int j = i * 2; j < MAX; j+=i){ use[j] = true; } } } scanf("%d", &n); int ans = 0; for (int i = 0; i < n; i++){ long long int a; scanf("%lld", &a); for (int j = 0; pr[j] * pr[j] * pr[j] <= a; j++){ while (a % (pr[j] * pr[j] * pr[j]) == 0){ a /= (pr[j] * pr[j] * pr[j]); } } if (a == 1){ mpp[1]++; mp2[1]++; continue; } long long int val = a; if (mp.count(a)){ mpp[mp[a]]++; mp2[val]++; continue; } int siz = pr.size(); long long int v = 1; for (int j = 0; j<siz&&pr[j] * pr[j] <= a; j++){ int cnt = 0; while (a%pr[j] == 0LL){ a /= pr[j]; cnt++; } if (cnt){ v *= pr[j]; if (cnt == 1){ v *= pr[j]; } } if (v > 10000000000LL){ break; } } if (v<=10000000000LL&&a){ v *= a; if (v <= 10000000000LL){ v *= a; } } if (v > 10000000000LL){ v = -1; } mp[v] = val; mp[val] = v; mpp[v]++; mp2[val]++; } long long int way = 0; for (auto it = mpp.begin(); it != mpp.end(); it++){ if ((*it).first == 1LL){ ans++; continue; } if ((*it).first == -1LL){ ans += (*it).second; continue; } if (mp2.count((*it).first)){ way += max((*it).second, mp2[(*it).first]); } else{ ans += (*it).second; } } way /= 2LL; printf("%lld\n", ans + way); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Anticube |
User | Kmcode |
Language | C++14 (GCC 5.4.1) |
Score | 1100 |
Code Size | 1780 Byte |
Status | AC |
Exec Time | 4558 ms |
Memory | 14736 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:26:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:30:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld", &a); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1100 / 1100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 2698 ms | 8776 KB |
02.txt | AC | 2749 ms | 8776 KB |
03.txt | AC | 2716 ms | 8776 KB |
04.txt | AC | 2700 ms | 8776 KB |
05.txt | AC | 2690 ms | 8776 KB |
06.txt | AC | 2715 ms | 8776 KB |
07.txt | AC | 2669 ms | 8776 KB |
08.txt | AC | 2729 ms | 8776 KB |
09.txt | AC | 2736 ms | 8776 KB |
10.txt | AC | 2676 ms | 8776 KB |
11.txt | AC | 4432 ms | 4364 KB |
12.txt | AC | 4447 ms | 4364 KB |
13.txt | AC | 613 ms | 4376 KB |
14.txt | AC | 632 ms | 4376 KB |
15.txt | AC | 627 ms | 4376 KB |
16.txt | AC | 631 ms | 4376 KB |
17.txt | AC | 71 ms | 512 KB |
18.txt | AC | 71 ms | 512 KB |
19.txt | AC | 73 ms | 512 KB |
20.txt | AC | 71 ms | 512 KB |
21.txt | AC | 3360 ms | 6576 KB |
22.txt | AC | 3381 ms | 6576 KB |
23.txt | AC | 3349 ms | 6576 KB |
24.txt | AC | 3341 ms | 6576 KB |
25.txt | AC | 3360 ms | 6576 KB |
26.txt | AC | 3357 ms | 6576 KB |
27.txt | AC | 211 ms | 14736 KB |
28.txt | AC | 22 ms | 512 KB |
29.txt | AC | 27 ms | 512 KB |
30.txt | AC | 30 ms | 512 KB |
31.txt | AC | 30 ms | 512 KB |
32.txt | AC | 30 ms | 512 KB |
33.txt | AC | 6 ms | 512 KB |
34.txt | AC | 65 ms | 512 KB |
35.txt | AC | 57 ms | 512 KB |
36.txt | AC | 5 ms | 512 KB |
37.txt | AC | 4558 ms | 4760 KB |
38.txt | AC | 4491 ms | 4760 KB |
39.txt | AC | 4474 ms | 4760 KB |
40.txt | AC | 4482 ms | 4760 KB |
41.txt | AC | 5 ms | 512 KB |
42.txt | AC | 5 ms | 512 KB |
43.txt | AC | 6 ms | 512 KB |
44.txt | AC | 5 ms | 512 KB |
45.txt | AC | 5 ms | 512 KB |
46.txt | AC | 5 ms | 512 KB |
47.txt | AC | 5 ms | 512 KB |
48.txt | AC | 5 ms | 512 KB |
s1.txt | AC | 5 ms | 512 KB |
s2.txt | AC | 5 ms | 512 KB |
s3.txt | AC | 5 ms | 512 KB |