Submission #1366100
Source Code Expand
#include <cstdio> #include <map> #include <cstdlib> #include <algorithm> #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 struct myc{ int x; ll y; }; std::map <ll, int> p2; std::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){ if(a > LIM) exit(1); if(b > LIM) exit(2); if(b < 0) exit(3); 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; fscanf(fin, "%d", &n); int ans = 0; bool cub = 0; for(int i = 1; i <= n; i ++){ ll x, imag = 1, rev = 1; fscanf(fin, "%lld", &x); 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) 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){ if(t[i] == 1) return 4; 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 | 0 |
Code Size | 2518 Byte |
Status | WA |
Exec Time | 530 ms |
Memory | 8448 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:128:32: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘int’ [-Wformat=] fprintf(fout, "%lld\n", ans); ^ ./Main.cpp:76:26: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] fscanf(fin, "%d", &n); ^ ./Main.cpp:82:32: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] fscanf(fin, "%lld", &x); ^
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 | 527 ms | 5760 KB |
02.txt | AC | 526 ms | 5760 KB |
03.txt | AC | 528 ms | 5760 KB |
04.txt | AC | 530 ms | 5760 KB |
05.txt | AC | 526 ms | 5760 KB |
06.txt | AC | 528 ms | 5760 KB |
07.txt | AC | 529 ms | 5760 KB |
08.txt | AC | 528 ms | 5760 KB |
09.txt | AC | 528 ms | 5760 KB |
10.txt | AC | 530 ms | 5760 KB |
11.txt | AC | 527 ms | 2816 KB |
12.txt | AC | 527 ms | 2816 KB |
13.txt | WA | 524 ms | 3712 KB |
14.txt | WA | 524 ms | 3712 KB |
15.txt | WA | 524 ms | 3712 KB |
16.txt | WA | 524 ms | 3712 KB |
17.txt | AC | 59 ms | 896 KB |
18.txt | AC | 60 ms | 896 KB |
19.txt | AC | 60 ms | 896 KB |
20.txt | AC | 59 ms | 896 KB |
21.txt | WA | 418 ms | 4608 KB |
22.txt | WA | 417 ms | 4608 KB |
23.txt | WA | 419 ms | 4608 KB |
24.txt | WA | 419 ms | 4608 KB |
25.txt | WA | 419 ms | 4608 KB |
26.txt | WA | 416 ms | 4608 KB |
27.txt | AC | 283 ms | 8448 KB |
28.txt | AC | 10 ms | 896 KB |
29.txt | AC | 17 ms | 896 KB |
30.txt | AC | 19 ms | 896 KB |
31.txt | AC | 19 ms | 896 KB |
32.txt | AC | 20 ms | 896 KB |
33.txt | AC | 3 ms | 896 KB |
34.txt | AC | 58 ms | 896 KB |
35.txt | AC | 52 ms | 896 KB |
36.txt | AC | 3 ms | 896 KB |
37.txt | WA | 511 ms | 3328 KB |
38.txt | WA | 511 ms | 3328 KB |
39.txt | WA | 510 ms | 3328 KB |
40.txt | WA | 509 ms | 3328 KB |
41.txt | AC | 3 ms | 896 KB |
42.txt | AC | 3 ms | 896 KB |
43.txt | AC | 3 ms | 896 KB |
44.txt | AC | 3 ms | 896 KB |
45.txt | AC | 3 ms | 896 KB |
46.txt | AC | 3 ms | 896 KB |
47.txt | AC | 3 ms | 896 KB |
48.txt | AC | 3 ms | 896 KB |
s1.txt | AC | 3 ms | 896 KB |
s2.txt | AC | 3 ms | 896 KB |
s3.txt | AC | 3 ms | 896 KB |