Submission #1366121
Source Code Expand
#include <cstdio> #include <unordered_map> #include <algorithm> #include <cctype> #define fin stdin #define fout stdout #define x first #define y second #define ll long long #define LIM (10LL * 1000 * 1000 * 1000) #define MAXR 100000 #define MAXC 3200 #define MAX0 452 #define MAXN 100000 #define BUF_SIZE 1<<17 int pos = BUF_SIZE; char buf[BUF_SIZE]; inline char nextch(){ if(pos == BUF_SIZE) fread(buf, BUF_SIZE, 1, fin), pos=0; return buf[pos ++]; } inline ll read(){ ll x = 0; char ch = fgetc(fin); while(!isdigit(ch)) ch=fgetc(fin); while(isdigit(ch)){ x = 10 * x + ch - '0'; ch = fgetc(fin); } return x; } struct myc{ int x; ll y; }; std::unordered_map <ll, int> p2; std::unordered_map <ll, myc> mp; int pr[MAX0 + 1]; bool c[MAXR + 1]; ll t[MAXN + 1]; int k; inline void add(ll a, ll b){ auto &u = mp[a]; u.x ++; u.y = b; if(u.x == 1) t[++ k] = a; } inline void inmult(ll &a, ll b){ if(a > 0){ a *= b; if(a > LIM) a = -1; } } int main(){ for(int i = 2; i * i <= MAXR; i ++) if(c[i] == 0) for(int j = i * i; j <= MAXR; j += i) c[j] = 1; for(int i = 2; i <= MAXC; i ++) if(c[i] == 0) pr[++ pr[0]] = i; //printf("%d", pr[0]); for(int i = MAXC + 1; i <= MAXR; i ++) if(c[i] == 0) p2[1LL * i * i] = i; int n = read(); int ans = 0; bool cub = 0; for(int i = 1; i <= n; i ++){ ll x = read(), imag = 1, rev = 1; int q = 1; while(q <= pr[0] && x != 1){ int s = 0; while(x % pr[q] == 0) s ++, x /= pr[q]; s %= 3; if(s > 0){ for(int j = 0; j < s; j ++) imag *= pr[q]; for(int j = 0; j < 3 - s; j ++) inmult(rev, pr[q]); } q ++; } if(x == 1){ if(rev == -1) ans ++; else if(rev == 1) cub = 1; else add(imag, rev); }else{ int u = p2[x]; if(u == 0){ if(x <= MAXR){ inmult(rev, x); inmult(rev, x); if(rev == -1) ans ++; else add(imag * x, rev); }else ans ++; }else{ inmult(rev, u); if(rev == -1) ans ++; else add(imag * x, rev); } } } ans += cub; for(int i = 1; i <= k; i ++){ auto &u = mp[t[i]]; if(u.x){ auto &v = mp[u.y]; ans += std::max(u.x, v.x); v.x = 0; u.x=0; } } fprintf(fout, "%lld\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Anticube |
User | alexpetrescu |
Language | C++14 (GCC 5.4.1) |
Score | 1100 |
Code Size | 2960 Byte |
Status | AC |
Exec Time | 512 ms |
Memory | 11464 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:144:32: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘int’ [-Wformat=] fprintf(fout, "%lld\n", ans); ^
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 | 512 ms | 4132 KB |
02.txt | AC | 512 ms | 4132 KB |
03.txt | AC | 508 ms | 4132 KB |
04.txt | AC | 510 ms | 4132 KB |
05.txt | AC | 508 ms | 4132 KB |
06.txt | AC | 508 ms | 4004 KB |
07.txt | AC | 510 ms | 4132 KB |
08.txt | AC | 510 ms | 4132 KB |
09.txt | AC | 512 ms | 4132 KB |
10.txt | AC | 512 ms | 4132 KB |
11.txt | AC | 499 ms | 2060 KB |
12.txt | AC | 499 ms | 2060 KB |
13.txt | AC | 500 ms | 3212 KB |
14.txt | AC | 499 ms | 3212 KB |
15.txt | AC | 498 ms | 3212 KB |
16.txt | AC | 499 ms | 3212 KB |
17.txt | AC | 55 ms | 768 KB |
18.txt | AC | 55 ms | 768 KB |
19.txt | AC | 55 ms | 768 KB |
20.txt | AC | 55 ms | 768 KB |
21.txt | AC | 403 ms | 3340 KB |
22.txt | AC | 406 ms | 3340 KB |
23.txt | AC | 400 ms | 3468 KB |
24.txt | AC | 402 ms | 3340 KB |
25.txt | AC | 403 ms | 3340 KB |
26.txt | AC | 401 ms | 3340 KB |
27.txt | AC | 290 ms | 11464 KB |
28.txt | AC | 5 ms | 768 KB |
29.txt | AC | 12 ms | 768 KB |
30.txt | AC | 15 ms | 768 KB |
31.txt | AC | 15 ms | 768 KB |
32.txt | AC | 15 ms | 768 KB |
33.txt | AC | 3 ms | 768 KB |
34.txt | AC | 55 ms | 768 KB |
35.txt | AC | 49 ms | 768 KB |
36.txt | AC | 3 ms | 768 KB |
37.txt | AC | 491 ms | 2444 KB |
38.txt | AC | 491 ms | 2444 KB |
39.txt | AC | 488 ms | 2444 KB |
40.txt | AC | 489 ms | 2444 KB |
41.txt | AC | 3 ms | 768 KB |
42.txt | AC | 3 ms | 768 KB |
43.txt | AC | 3 ms | 768 KB |
44.txt | AC | 3 ms | 768 KB |
45.txt | AC | 3 ms | 768 KB |
46.txt | AC | 3 ms | 768 KB |
47.txt | AC | 3 ms | 768 KB |
48.txt | AC | 3 ms | 768 KB |
s1.txt | AC | 3 ms | 768 KB |
s2.txt | AC | 3 ms | 768 KB |
s3.txt | AC | 3 ms | 768 KB |