Submission #846721
Source Code Expand
Copy
/* */ #define _CRT_SECURE_NO_WARNINGS //#pragma comment(linker, "/STACK:16777216") #include <fstream> #include <iostream> #include <string> #include <complex> #include <math.h> #include <set> #include <vector> #include <map> #include <queue> #include <stdio.h> #include <stack> #include <algorithm> #include <list> #include <ctime> #include <memory.h> #include <ctime> #include <assert.h> #define y0 sdkfaslhagaklsldk #define y1 aasdfasdfasdf #define yn askfhwqriuperikldjk #define j1 assdgsdgasghsf #define tm sdfjahlfasfh #define lr asgasgash #define eps 1e-10 #define M_PI 3.141592653589793 #define bs 1000000007; #define bsize 512 const int N = 233031; using namespace std; int n; int pr[N]; vector<int> primes; map<vector<pair<long long, long long> >, int> have; map<vector<pair<long long, long long> >, int>::iterator it; long long ans; vector<pair<long long, long long> > paired(vector<pair<long long, long long> > v) { vector<pair<long long, long long> > res; for (int i = 0; i < v.size(); i++) { if (v[i].second == -1) { res.push_back(make_pair(-1, -1)); return res; } } for (int i = 0; i < v.size(); i++) { res.push_back(v[i]); res[i].second = 3 - res[i].second; res[i].second %= 3; } } bool perf_square(long long x) { long long val = sqrt(x + .5); return (val*val == x); } vector<pair<long long, long long> > parse(long long x) { vector<pair<long long, long long> > res; for (int i = 0; i < primes.size(); i++) { if (x%primes[i]) continue; int cnt = 0; while (x%primes[i] == 0) { cnt++; x /= primes[i]; } if (cnt % 3 == 0) continue; res.push_back(make_pair(primes[i], cnt % 3)); } if (x == 1) return res; if (perf_square(x)) { int ss = sqrt(x + .5); res.push_back(make_pair(ss, 2)); return res; } if (x <= 100000) { res.push_back(make_pair(x, 1)); return res; } res.push_back(make_pair(1, -1)); return res; } int main(){ //freopen("beavers.in","r",stdin); //freopen("beavers.out","w",stdout); //freopen("F:/in.txt","r",stdin); //freopen("F:/output.txt","w",stdout); ios_base::sync_with_stdio(0); //cin.tie(0); cin >> n; pr[1] = 1; for (int i = 2; i <= 10000; i++) { if (pr[i] == 0) { for (int j = i * 2; j <= 10000; j+=i) { pr[j] = 1; } } } for (int i = 2; i <= 3000; i++) { if (pr[i] == 0) { primes.push_back(i); } } for (int i = 1; i <= n; i++) { long long val; cin >> val; vector<pair<long long, long long> > p = parse(val); /*for (int j = 0; j < p.size(); j++) { cout << p[j].first << "%" << p[j].second << endl; } cout << "!" << endl; */ have[p]++; } for (it = have.begin(); it != have.end(); it++) { int cnt = (*it).second; vector<pair<long long, long long> > p = (*it).first; vector<pair<long long, long long> > p2 = paired(p); if (p2 == p) { ans += 2; continue; } if (have.find(p2) == have.end()) { ans += cnt * 2; continue; } ans += max(have[p2], have[p]); } cout << ans / 2 << endl; cin.get(); cin.get(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Anticube |
User | LeBron |
Language | C++14 (GCC 5.4.1) |
Score | 1100 |
Code Size | 3220 Byte |
Status | AC |
Exec Time | 996 ms |
Memory | 11520 KB |
Compile Error
./Main.cpp:32:0: warning: "M_PI" redefined #define M_PI 3.141592653589793 ^ In file included from /usr/include/c++/5/cmath:44:0, from /usr/include/c++/5/complex:44, from ./Main.cpp:9: /usr/include/math.h:372:0: note: this is the location of the previous definition # define M_PI 3.14159265358979323846 /* pi */ ^
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 | 949 ms | 6656 KB |
02.txt | AC | 930 ms | 6656 KB |
03.txt | AC | 924 ms | 6656 KB |
04.txt | AC | 934 ms | 6656 KB |
05.txt | AC | 959 ms | 6656 KB |
06.txt | AC | 931 ms | 6656 KB |
07.txt | AC | 936 ms | 6656 KB |
08.txt | AC | 923 ms | 6656 KB |
09.txt | AC | 932 ms | 6528 KB |
10.txt | AC | 929 ms | 6656 KB |
11.txt | AC | 789 ms | 256 KB |
12.txt | AC | 788 ms | 256 KB |
13.txt | AC | 822 ms | 1920 KB |
14.txt | AC | 826 ms | 1920 KB |
15.txt | AC | 832 ms | 1920 KB |
16.txt | AC | 825 ms | 1920 KB |
17.txt | AC | 889 ms | 256 KB |
18.txt | AC | 884 ms | 256 KB |
19.txt | AC | 885 ms | 256 KB |
20.txt | AC | 889 ms | 256 KB |
21.txt | AC | 872 ms | 2688 KB |
22.txt | AC | 877 ms | 2816 KB |
23.txt | AC | 877 ms | 2816 KB |
24.txt | AC | 875 ms | 2816 KB |
25.txt | AC | 868 ms | 2688 KB |
26.txt | AC | 868 ms | 2816 KB |
27.txt | AC | 996 ms | 11520 KB |
28.txt | AC | 789 ms | 256 KB |
29.txt | AC | 793 ms | 256 KB |
30.txt | AC | 825 ms | 256 KB |
31.txt | AC | 813 ms | 256 KB |
32.txt | AC | 815 ms | 256 KB |
33.txt | AC | 4 ms | 256 KB |
34.txt | AC | 894 ms | 256 KB |
35.txt | AC | 854 ms | 256 KB |
36.txt | AC | 4 ms | 256 KB |
37.txt | AC | 811 ms | 768 KB |
38.txt | AC | 818 ms | 768 KB |
39.txt | AC | 820 ms | 768 KB |
40.txt | AC | 808 ms | 768 KB |
41.txt | AC | 4 ms | 256 KB |
42.txt | AC | 4 ms | 256 KB |
43.txt | AC | 4 ms | 256 KB |
44.txt | AC | 5 ms | 256 KB |
45.txt | AC | 5 ms | 256 KB |
46.txt | AC | 4 ms | 256 KB |
47.txt | AC | 5 ms | 256 KB |
48.txt | AC | 4 ms | 256 KB |
s1.txt | AC | 5 ms | 256 KB |
s2.txt | AC | 4 ms | 256 KB |
s3.txt | AC | 5 ms | 256 KB |