Submission #1687349
Source Code Expand
#include <stdio.h> #include <iostream> #include <algorithm> #include <memory.h> #include <math.h> 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;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*=x*x; if (cnt==2) u*=x*x,v*=x; } LL n_=sqrt(n); if (n_*n_==n) u*=n,v*=n_; else if (n>(int)1e5) {ans++;return ;} else {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)2200); 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[ord[pos]]==t[ord[i]]) { a[ord[pos]]==a[ord[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 | 1100 |
Code Size | 1419 Byte |
Status | AC |
Exec Time | 390 ms |
Memory | 2176 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:53:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n);predo((int)2200); ^ ./Main.cpp:54: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 | 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 | 358 ms | 1280 KB |
02.txt | AC | 358 ms | 1280 KB |
03.txt | AC | 358 ms | 1280 KB |
04.txt | AC | 358 ms | 1280 KB |
05.txt | AC | 358 ms | 1280 KB |
06.txt | AC | 358 ms | 1280 KB |
07.txt | AC | 358 ms | 1280 KB |
08.txt | AC | 358 ms | 1280 KB |
09.txt | AC | 358 ms | 1280 KB |
10.txt | AC | 358 ms | 1280 KB |
11.txt | AC | 344 ms | 1024 KB |
12.txt | AC | 344 ms | 1024 KB |
13.txt | AC | 346 ms | 1408 KB |
14.txt | AC | 346 ms | 1408 KB |
15.txt | AC | 346 ms | 1408 KB |
16.txt | AC | 346 ms | 1408 KB |
17.txt | AC | 389 ms | 2176 KB |
18.txt | AC | 390 ms | 2176 KB |
19.txt | AC | 390 ms | 2176 KB |
20.txt | AC | 390 ms | 2176 KB |
21.txt | AC | 361 ms | 1536 KB |
22.txt | AC | 361 ms | 1536 KB |
23.txt | AC | 361 ms | 1536 KB |
24.txt | AC | 361 ms | 1536 KB |
25.txt | AC | 361 ms | 1536 KB |
26.txt | AC | 361 ms | 1536 KB |
27.txt | AC | 362 ms | 2176 KB |
28.txt | AC | 340 ms | 1024 KB |
29.txt | AC | 346 ms | 1024 KB |
30.txt | AC | 351 ms | 2176 KB |
31.txt | AC | 351 ms | 2176 KB |
32.txt | AC | 352 ms | 2176 KB |
33.txt | AC | 1 ms | 256 KB |
34.txt | AC | 385 ms | 2176 KB |
35.txt | AC | 379 ms | 1024 KB |
36.txt | AC | 1 ms | 256 KB |
37.txt | AC | 348 ms | 1152 KB |
38.txt | AC | 347 ms | 1152 KB |
39.txt | AC | 347 ms | 1152 KB |
40.txt | AC | 347 ms | 1152 KB |
41.txt | AC | 1 ms | 256 KB |
42.txt | AC | 1 ms | 256 KB |
43.txt | AC | 1 ms | 256 KB |
44.txt | AC | 1 ms | 256 KB |
45.txt | AC | 1 ms | 256 KB |
46.txt | AC | 1 ms | 256 KB |
47.txt | AC | 1 ms | 256 KB |
48.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | AC | 1 ms | 256 KB |