Submission #1832975
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 unsigned 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 ano = 1 , yuan = x; int now;int push; for(int i = 1;i <= cnt;++ i) { if(ano > 1e10) { ans ++; return; } if(x < luck[i]) { int y = sqrt(x); if(y == 1) y = 0; if(y >= 1) y --; while(y * y < x) ++ y; if(y * y > x) { if(x <= 100000 && isp[x]) { if(ano * x > (1e10) / (double) x - 10) { ans ++; return; } ano *= x * x; x = 1; break; } else { ans ++; return; } } else { ano *= y; x = 1; break; } } if(x == 1) break; if(x < pr[i] * pr[i]) { if(x <= 100000 && isp[x]) { if(ano * x > (1e15) / (double) x - 10) { ans ++; return; } ano *= x * x; x = 1; break; } else { ans ++; return; } } now = luck[i]; while(x % now == 0) x /= now , yuan /= now; if(x % pr[i] == 0) { push = pr[i] * pr[i]; if(x % push) push = pr[i]; x /= push; ano = ano * (now / push); if(ano > 1e10) { ans ++; return; } } if(ano > 1e10) { ans ++; return; } } if(x != 1) { ans ++; return; } Vec.pb(mp(yuan , ano)); // cerr << yuan << " " << ano << endl; Map[yuan] ++; } 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(1e5 + 2); 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 | 0 |
Code Size | 2508 Byte |
Status | WA |
Exec Time | 543 ms |
Memory | 9328 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:125:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld" , &n); ^ ./Main.cpp:126: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 | 0 / 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 | 219 ms | 1280 KB |
02.txt | AC | 219 ms | 1280 KB |
03.txt | AC | 219 ms | 1280 KB |
04.txt | AC | 219 ms | 1280 KB |
05.txt | AC | 218 ms | 1280 KB |
06.txt | AC | 218 ms | 1280 KB |
07.txt | AC | 217 ms | 1280 KB |
08.txt | AC | 219 ms | 1280 KB |
09.txt | AC | 219 ms | 1280 KB |
10.txt | AC | 219 ms | 1280 KB |
11.txt | AC | 543 ms | 1280 KB |
12.txt | AC | 543 ms | 1280 KB |
13.txt | AC | 120 ms | 2936 KB |
14.txt | AC | 121 ms | 2936 KB |
15.txt | AC | 123 ms | 2936 KB |
16.txt | AC | 121 ms | 2936 KB |
17.txt | WA | 47 ms | 3452 KB |
18.txt | WA | 47 ms | 3452 KB |
19.txt | WA | 47 ms | 3452 KB |
20.txt | WA | 47 ms | 3452 KB |
21.txt | WA | 235 ms | 2416 KB |
22.txt | WA | 234 ms | 2420 KB |
23.txt | WA | 234 ms | 2412 KB |
24.txt | WA | 234 ms | 2412 KB |
25.txt | WA | 235 ms | 2420 KB |
26.txt | WA | 235 ms | 2416 KB |
27.txt | WA | 78 ms | 9328 KB |
28.txt | AC | 14 ms | 3444 KB |
29.txt | AC | 17 ms | 3444 KB |
30.txt | AC | 17 ms | 3444 KB |
31.txt | AC | 18 ms | 3444 KB |
32.txt | AC | 18 ms | 3444 KB |
33.txt | AC | 2 ms | 512 KB |
34.txt | AC | 41 ms | 3444 KB |
35.txt | AC | 37 ms | 3444 KB |
36.txt | AC | 2 ms | 512 KB |
37.txt | WA | 489 ms | 1536 KB |
38.txt | WA | 488 ms | 1536 KB |
39.txt | WA | 488 ms | 1536 KB |
40.txt | WA | 489 ms | 1536 KB |
41.txt | AC | 2 ms | 512 KB |
42.txt | AC | 2 ms | 512 KB |
43.txt | AC | 2 ms | 512 KB |
44.txt | AC | 2 ms | 512 KB |
45.txt | AC | 2 ms | 512 KB |
46.txt | AC | 2 ms | 512 KB |
47.txt | AC | 2 ms | 512 KB |
48.txt | AC | 2 ms | 512 KB |
s1.txt | AC | 2 ms | 512 KB |
s2.txt | AC | 3 ms | 512 KB |
s3.txt | AC | 2 ms | 512 KB |