Submission #1687305
Source Code Expand
#include <stdio.h> #include <iostream> #include <algorithm> #include <memory.h> #include <vector> using namespace std; typedef long long LL; const int maxn = 100005; LL a[maxn],t[maxn];int n,cnt,m,ans; int prm[maxn],tot,is[maxn],ord[maxn]; void predo(int n) { for (int i=2;i<=n;i++) { if (!is[i]) prm[++tot]=i; for (int j=1;j<=tot;j++) { int num=prm[j]*i; if (num>n) break; if (i%prm[j]) is[num]=1; else {is[num]=1;break;} } } } void solve(LL n) { LL u=1ll,v=1ll; for (int i=1;i<=tot&&prm[i]<=n/prm[i];i++) if (n%prm[i]==0) { int cnt=0,x=prm[i]; while (n%x==0) n/=x,++cnt; cnt%=3; if (cnt==1) u*=x,v*=(LL)x*x; if (cnt==2) u*=(LL)x*x,v*=x; } if (n>1) u*=n,v*=n*n; if (u==1) ++cnt; else t[++m]=min(u,v),a[m]=v; } bool comp(int x,int y) {return t[x]<t[y];} int main() { #ifdef Amberframe freopen("agc003d.in","r",stdin); freopen("agc003d.out","w",stdout); #endif scanf("%d",&n);predo((int)1e5); for (int i=1;i<=n;i++) scanf("%lld",&a[i]); for (int i=1;i<=n;i++) solve(a[i]); for (int i=1;i<=m;i++) ord[i]=i; sort(ord+1,ord+m+1,comp); for (int i=1;i<=m;) { int pos=i,c1=0,c2=0; while (pos<=n&&t[pos]==t[i]) { a[pos]==a[i]?c1++:c2++;++pos; } ans+=max(c1,c2);i=pos; } printf("%d",ans+(cnt?1:0)); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Anticube |
User | Amberframe |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1339 Byte |
Status | WA |
Exec Time | 5255 ms |
Memory | 2688 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:50:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n);predo((int)1e5); ^ ./Main.cpp:51:44: 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 | 2267 ms | 2688 KB |
02.txt | AC | 2287 ms | 2688 KB |
03.txt | AC | 2277 ms | 2560 KB |
04.txt | AC | 2267 ms | 2560 KB |
05.txt | AC | 2243 ms | 2560 KB |
06.txt | AC | 2262 ms | 2688 KB |
07.txt | AC | 2246 ms | 2688 KB |
08.txt | AC | 2276 ms | 2688 KB |
09.txt | AC | 2273 ms | 2560 KB |
10.txt | AC | 2251 ms | 2560 KB |
11.txt | TLE | 5255 ms | 1792 KB |
12.txt | TLE | 5255 ms | 1792 KB |
13.txt | WA | 1564 ms | 2560 KB |
14.txt | WA | 1579 ms | 2688 KB |
15.txt | WA | 1591 ms | 2688 KB |
16.txt | WA | 1595 ms | 2688 KB |
17.txt | WA | 66 ms | 2560 KB |
18.txt | WA | 66 ms | 2560 KB |
19.txt | WA | 66 ms | 2560 KB |
20.txt | WA | 66 ms | 2560 KB |
21.txt | WA | 4266 ms | 2688 KB |
22.txt | WA | 4256 ms | 2688 KB |
23.txt | WA | 4247 ms | 2688 KB |
24.txt | WA | 4239 ms | 2560 KB |
25.txt | WA | 4287 ms | 2560 KB |
26.txt | WA | 4261 ms | 2688 KB |
27.txt | WA | 67 ms | 2688 KB |
28.txt | AC | 11 ms | 1408 KB |
29.txt | AC | 19 ms | 1408 KB |
30.txt | AC | 25 ms | 2688 KB |
31.txt | AC | 23 ms | 2688 KB |
32.txt | AC | 23 ms | 2560 KB |
33.txt | AC | 2 ms | 640 KB |
34.txt | AC | 65 ms | 2688 KB |
35.txt | AC | 56 ms | 1408 KB |
36.txt | AC | 2 ms | 640 KB |
37.txt | TLE | 5255 ms | 1792 KB |
38.txt | TLE | 5255 ms | 1792 KB |
39.txt | TLE | 5255 ms | 1792 KB |
40.txt | TLE | 5255 ms | 1792 KB |
41.txt | AC | 2 ms | 640 KB |
42.txt | AC | 2 ms | 640 KB |
43.txt | AC | 2 ms | 640 KB |
44.txt | WA | 2 ms | 640 KB |
45.txt | AC | 2 ms | 640 KB |
46.txt | AC | 2 ms | 640 KB |
47.txt | AC | 2 ms | 640 KB |
48.txt | AC | 2 ms | 640 KB |
s1.txt | WA | 2 ms | 640 KB |
s2.txt | AC | 2 ms | 640 KB |
s3.txt | AC | 2 ms | 640 KB |