Submission #1832988
Source Code Expand
%:pragma GCC optimize(2) #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <cmath> #include <map> #include <vector> using namespace std; #define int long long const int N = 1e5 + 5; int n , m , x , y , cnt , ans , tot; int pr[N] , a[N] , luck[N]; bool isp[N]; map<int , int>Map; void prework(int n) { memset(isp , 1 , sizeof(isp)); isp[1] = 0; for(int i = 2;i <= n;++ i) { if(isp[i]) pr[++ cnt] = i , luck[cnt] = i * i * i; for(int j = 1;j <= cnt && pr[j] * i <= n;++ j) { isp[pr[j] * i] = 0; if(i % pr[j] == 0) break; } } } vector< pair<int,int> > Vec; #define mp(x , y) make_pair(x , y) #define pb push_back void chg(int x) { int a , b; a = 1; b = 1; for(int i = 1;i <= cnt;++ i) { int tot = 0; while(x % pr[i] == 0) { ++ tot; x /= pr[i]; } tot %= 3; if(!tot) continue; int ano = 3 - tot; while(tot --) a *= pr[i]; while(ano --) b *= pr[i]; if(b > 1e10) { ans ++; return; } } int y = sqrt(a); y --; y = max(y , 0ll); while(y * y < x) ++ y; if(y * y != x) { a *= x; b *= x; if(b > (1e10) / (double)x - 5) { ans ++; return; } b *= x; } else { a *= x; b *= y; if(b > 1e10) { ans ++; return; } } Map[a] ++; Vec.push_back(mp(a , b)); } void dance(void) { for(int i = 0;i < (int) Vec.size(); ++ i) { if(Vec[i].first == 1 && Map[1]) { ans ++; Map[1] = 0; continue; } if(Map[Vec[i].first]) { ans += max(Map[Vec[i].first] , Map[Vec[i].second]); Map[Vec[i].first] = Map[Vec[i].second] = 0; } } cout << ans << endl; } main(void) { // freopen("data.txt" , "r" , stdin); scanf("%lld" , &n); for(int i = 1;i <= n;++ i) scanf("%lld" , &a[i]); prework(3000); for(int i = 1;i <= n;++ i) { chg(a[i]); // if(i % 1000 == 0) cerr << i << endl; } dance(); }
Submission Info
Submission Time | |
---|---|
Task | D - Anticube |
User | Timsei |
Language | C++14 (GCC 5.4.1) |
Score | 1100 |
Code Size | 1893 Byte |
Status | AC |
Exec Time | 4699 ms |
Memory | 13040 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:92:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld" , &n); ^ ./Main.cpp:93:50: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] for(int i = 1;i <= n;++ i) scanf("%lld" , &a[i]); ^
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 | 1216 ms | 1152 KB |
02.txt | AC | 1217 ms | 1152 KB |
03.txt | AC | 1217 ms | 1152 KB |
04.txt | AC | 1214 ms | 1152 KB |
05.txt | AC | 1207 ms | 1152 KB |
06.txt | AC | 1209 ms | 1152 KB |
07.txt | AC | 1204 ms | 1152 KB |
08.txt | AC | 1217 ms | 1152 KB |
09.txt | AC | 1219 ms | 1152 KB |
10.txt | AC | 1209 ms | 1152 KB |
11.txt | AC | 4694 ms | 1152 KB |
12.txt | AC | 4699 ms | 1152 KB |
13.txt | AC | 943 ms | 2680 KB |
14.txt | AC | 948 ms | 2680 KB |
15.txt | AC | 953 ms | 2808 KB |
16.txt | AC | 953 ms | 2808 KB |
17.txt | AC | 509 ms | 3324 KB |
18.txt | AC | 508 ms | 3324 KB |
19.txt | AC | 509 ms | 3324 KB |
20.txt | AC | 509 ms | 3324 KB |
21.txt | AC | 1848 ms | 2284 KB |
22.txt | AC | 1843 ms | 2288 KB |
23.txt | AC | 1841 ms | 2280 KB |
24.txt | AC | 1838 ms | 2280 KB |
25.txt | AC | 1857 ms | 2288 KB |
26.txt | AC | 1845 ms | 2284 KB |
27.txt | AC | 555 ms | 13040 KB |
28.txt | AC | 459 ms | 3316 KB |
29.txt | AC | 465 ms | 3316 KB |
30.txt | AC | 466 ms | 3316 KB |
31.txt | AC | 466 ms | 3316 KB |
32.txt | AC | 467 ms | 3316 KB |
33.txt | AC | 1 ms | 384 KB |
34.txt | AC | 503 ms | 3316 KB |
35.txt | AC | 497 ms | 3316 KB |
36.txt | AC | 1 ms | 384 KB |
37.txt | AC | 4218 ms | 1408 KB |
38.txt | AC | 4215 ms | 1408 KB |
39.txt | AC | 4212 ms | 1408 KB |
40.txt | AC | 4224 ms | 1408 KB |
41.txt | AC | 1 ms | 384 KB |
42.txt | AC | 1 ms | 384 KB |
43.txt | AC | 1 ms | 384 KB |
44.txt | AC | 1 ms | 384 KB |
45.txt | AC | 1 ms | 384 KB |
46.txt | AC | 1 ms | 384 KB |
47.txt | AC | 1 ms | 384 KB |
48.txt | AC | 1 ms | 384 KB |
s1.txt | AC | 1 ms | 384 KB |
s2.txt | AC | 1 ms | 384 KB |
s3.txt | AC | 1 ms | 384 KB |