Submission #846782
Source Code Expand
Copy
#include <cstdio> #include <cstdlib> #include <algorithm> #include <vector> #include <cmath> #include <map> #include <set> #define SIZE 100005 #define INF 100000000000000LL using namespace std; typedef long long int ll; map <ll,int> mp; map <ll,int>::iterator it; ll to(ll x) { for(ll i=2;;i++) { ll t=i*i*i; if(t>x) break; while(x%t==0) x/=t; } return x; } ll tg(ll x)//toしてる -> x=P*Q^2 に直したい -> そして、P^2*Qに { ll A=1,B=1; for(ll i=2;;i++) { if(i*i*i>x) break; int cnt=0; while(x%i==0) { x/=i; cnt++; } if(cnt==1) A*=i; else if(cnt==2) B*=i; } //x/(A*B^2)=C*D^2だから、C=1 or D=1 ll dt=(ll) floor(sqrt(x)+0.5); if(dt*dt==x) B*=dt; else A*=x; ll ret=A*B; if(ret>INF/A+1) ret=INF; else ret*=A; return ret; } int main() { int n; scanf("%d",&n); for(int i=0;i<n;i++) { ll x; scanf("%lld",&x); x=to(x); //printf("%lld ",x); mp[x]++; } //puts(""); int ret=0; set <ll> st; for(it=mp.begin();it!=mp.end();it++) { ll x=it->first; if(st.count(x)) continue; int cnt=it->second; ll t=tg(x); //if(x<=t) printf("%lld %lld : %d %d\n",x,t,mp[x],mp[t]); if(x!=t) ret+=max(cnt,mp[t]); else ret++; st.insert(t); } printf("%d\n",ret); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Anticube |
User | yutaka1999 |
Language | C++14 (GCC 5.4.1) |
Score | 1100 |
Code Size | 1319 Byte |
Status | AC |
Exec Time | 3654 ms |
Memory | 14336 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:54:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n); ^ ./Main.cpp:58:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld",&x); ^
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 | 3518 ms | 6784 KB |
02.txt | AC | 3507 ms | 6784 KB |
03.txt | AC | 3508 ms | 6784 KB |
04.txt | AC | 3514 ms | 6784 KB |
05.txt | AC | 3495 ms | 6784 KB |
06.txt | AC | 3516 ms | 6784 KB |
07.txt | AC | 3522 ms | 6784 KB |
08.txt | AC | 3499 ms | 6784 KB |
09.txt | AC | 3506 ms | 6784 KB |
10.txt | AC | 3492 ms | 6784 KB |
11.txt | AC | 3649 ms | 2176 KB |
12.txt | AC | 3654 ms | 2176 KB |
13.txt | AC | 535 ms | 5632 KB |
14.txt | AC | 542 ms | 5632 KB |
15.txt | AC | 544 ms | 5632 KB |
16.txt | AC | 559 ms | 5632 KB |
17.txt | AC | 61 ms | 256 KB |
18.txt | AC | 62 ms | 256 KB |
19.txt | AC | 61 ms | 256 KB |
20.txt | AC | 62 ms | 256 KB |
21.txt | AC | 2290 ms | 6016 KB |
22.txt | AC | 2273 ms | 6016 KB |
23.txt | AC | 2292 ms | 6016 KB |
24.txt | AC | 2283 ms | 6016 KB |
25.txt | AC | 2282 ms | 6016 KB |
26.txt | AC | 2277 ms | 6016 KB |
27.txt | AC | 249 ms | 14336 KB |
28.txt | AC | 17 ms | 256 KB |
29.txt | AC | 22 ms | 256 KB |
30.txt | AC | 19 ms | 256 KB |
31.txt | AC | 19 ms | 256 KB |
32.txt | AC | 19 ms | 256 KB |
33.txt | AC | 4 ms | 256 KB |
34.txt | AC | 53 ms | 256 KB |
35.txt | AC | 53 ms | 256 KB |
36.txt | AC | 4 ms | 256 KB |
37.txt | AC | 3473 ms | 3072 KB |
38.txt | AC | 3467 ms | 3072 KB |
39.txt | AC | 3464 ms | 3072 KB |
40.txt | AC | 3480 ms | 3200 KB |
41.txt | AC | 4 ms | 256 KB |
42.txt | AC | 4 ms | 256 KB |
43.txt | AC | 4 ms | 256 KB |
44.txt | AC | 4 ms | 256 KB |
45.txt | AC | 4 ms | 256 KB |
46.txt | AC | 4 ms | 256 KB |
47.txt | AC | 4 ms | 256 KB |
48.txt | AC | 4 ms | 256 KB |
s1.txt | AC | 4 ms | 256 KB |
s2.txt | AC | 4 ms | 256 KB |
s3.txt | AC | 4 ms | 256 KB |