Submission #1683926
Source Code Expand
//2017-10-14
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
#define LL long long
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define Forr(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define MN (2200+5)
#define N (100000+5)
inline LL Sqr(LL a){return a * a;}
inline LL Sqr3(LL a){return a * a * a;}
struct node{
LL x, y, tot;
}me[N];
LL a[N];
map<LL, int> ms;
int mn;
int main(){
int n, nn = 2200;
LL x, y, tmp, form;
scanf("%d", &n);
For(i, 1, n){
scanf("%lld", &a[i]);
Forr(j, (int)min((LL)pow(a[i], 1/3.0)+5, 1ll*nn), 2)
while(!(a[i] % Sqr3(j))) a[i] /= Sqr3(j);
if(ms.count(a[i])){
++me[ms[a[i]]].tot; continue;
}
form = a[i]; x = 1; y = 1;
Forr(j, (int)min((LL)sqrt(a[i]), 1ll*nn), 2)
while(!(a[i] % Sqr(j))) x *= j, a[i] /= Sqr(j);
Forr(j, (int)min(a[i], 1ll*nn), 2)
while(!(a[i] % j)) y *= j, a[i] /= j;
// printf("tmp[%d] = %lld (%lld %lld)\n", i, a[i], x, y);
tmp = sqrt(a[i]);
if(Sqr(tmp) == a[i]) x *= tmp;
else y *= a[i];
me[++mn] = (node){x, y, 1}; ms[a[i]=form] = mn;
}
// For(i, 1, n) printf("a[%d] = %lld\n", i, a[i]);
int ans = 0, id;
LL mv, ov;
if(ms.count(1)) ++ans, ms[1] = -1;
For(i, 1, n){
if(ms[mv = a[i]] == -1) continue;
id = ms[mv]; ov = me[id].x * Sqr(me[id].y);
if(!ms.count(ov)){ans += me[id].tot; ms[mv] = -1; continue;}
ans += max(me[id].tot, me[ms[ov]].tot);
ms[mv] = ms[ov] = -1;
}
printf("%d\n", ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
D - Anticube |
User |
miaomiao |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1642 Byte |
Status |
TLE |
Exec Time |
5256 ms |
Memory |
9600 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:36:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:39:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
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 |
TLE |
5256 ms |
7808 KB |
02.txt |
TLE |
5256 ms |
7808 KB |
03.txt |
TLE |
5256 ms |
7808 KB |
04.txt |
TLE |
5256 ms |
7808 KB |
05.txt |
TLE |
5256 ms |
9600 KB |
06.txt |
TLE |
5256 ms |
7808 KB |
07.txt |
TLE |
5256 ms |
7680 KB |
08.txt |
TLE |
5256 ms |
7680 KB |
09.txt |
TLE |
5256 ms |
7808 KB |
10.txt |
TLE |
5256 ms |
7808 KB |
11.txt |
AC |
3342 ms |
3712 KB |
12.txt |
AC |
3323 ms |
3712 KB |
13.txt |
AC |
1507 ms |
4224 KB |
14.txt |
AC |
1486 ms |
4224 KB |
15.txt |
AC |
1497 ms |
4224 KB |
16.txt |
AC |
1492 ms |
4224 KB |
17.txt |
AC |
816 ms |
1024 KB |
18.txt |
AC |
824 ms |
1024 KB |
19.txt |
AC |
828 ms |
1024 KB |
20.txt |
AC |
828 ms |
1024 KB |
21.txt |
AC |
3860 ms |
6272 KB |
22.txt |
AC |
3829 ms |
6272 KB |
23.txt |
AC |
3833 ms |
6272 KB |
24.txt |
AC |
3819 ms |
6272 KB |
25.txt |
AC |
3841 ms |
6272 KB |
26.txt |
AC |
3781 ms |
6272 KB |
27.txt |
AC |
2101 ms |
8192 KB |
28.txt |
AC |
18 ms |
1024 KB |
29.txt |
AC |
25 ms |
1024 KB |
30.txt |
AC |
24 ms |
1024 KB |
31.txt |
AC |
24 ms |
1024 KB |
32.txt |
AC |
24 ms |
1024 KB |
33.txt |
AC |
1 ms |
256 KB |
34.txt |
AC |
2387 ms |
1024 KB |
35.txt |
AC |
1126 ms |
1024 KB |
36.txt |
AC |
1 ms |
256 KB |
37.txt |
AC |
3523 ms |
4352 KB |
38.txt |
AC |
3502 ms |
4352 KB |
39.txt |
AC |
3515 ms |
4352 KB |
40.txt |
AC |
3502 ms |
4352 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 |
2 ms |
256 KB |