ソースコード 拡げる

Copy
```#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> PII;
typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pct __builtin_popcount

#define INF 10000000010LL

int p[1000], pb[1000], L; ll pc[1000];
int n; map<ll, int> F; map<ll, ll> ra;
set<ll> C;

int main () {
for (int i = 2; i < 3000; i ++) {
bool F = 1;
for (int j = 2; j*j <= i; j ++)
if (i%j == 0) {F = 0; break;}
if (F) {
p[L] = i;
pb[L] = i*i;
pc[L] = (ll)i*i*i;
L ++;
}
}
cin >> n;
int S = 0;
bool F1 = 0;
for (int i = 0; i < n; i ++) {
ll x;
cin >> x;
ll y = 1;
ll x1 = 1;
for (int j = 0; x != 1 && j < L; j ++) {
while (x%pc[j] == 0) {
x /= pc[j];
}
if (x%pb[j] == 0) {
y *= p[j];
x1 *= pb[j];
if (y > INF) y = INF;
} else
if (x%p[j] == 0) {
y *= pb[j];
x1 *= p[j];
if (y > INF) y = INF;
}
}
x /= x1;
if (y >= INF) {
S ++; continue;
}
if (x != 1) {
int c = sqrt(x); int cc = -1;
for (int d = max(1, c-10); d <= c+10; d ++)
if ((ll)d*d == x) {
cc = d; break;
}
if (cc == -1) {
if (INF/x/x < y) {S ++; continue;}
y *= x; y *= x;
} else {
y *= cc;
}
}
if (y >= INF) {
S ++; continue;
}
x *= x1;
if (x == 1) {
if (!F1) {
F1 = 1;
S ++;
}
continue;
}
F[x] ++;
ra[x] = y;
}

for (map<ll,int>::iterator i = F.begin(); i != F.end(); i ++) {
int r = ra[i->fi];
if (i->fi < r) {
S += max(i->se, F[r]);
}
}
cout << S << endl;
return 0;
}```

#### 提出情報

提出日時 2016-08-21 22:38:47+0900 D - Anticube sevenkplus C++14 (GCC 5.4.1) 0 1649 Byte WA 2455 ms 18432 KB

#### ジャッジ結果

セット名 Sample All

 AC × 3
 AC × 24 WA × 27
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
01.txt WA 2256 ms 256 KB
02.txt WA 2275 ms 256 KB
03.txt WA 2270 ms 256 KB
04.txt WA 2265 ms 256 KB
05.txt WA 2270 ms 256 KB
06.txt WA 2264 ms 256 KB
07.txt WA 2259 ms 256 KB
08.txt WA 2273 ms 256 KB
09.txt WA 2266 ms 256 KB
10.txt WA 2279 ms 256 KB
11.txt AC 2249 ms 256 KB
12.txt AC 2261 ms 256 KB
13.txt WA 2266 ms 2432 KB
14.txt WA 2265 ms 2432 KB
15.txt WA 2261 ms 2432 KB
16.txt WA 2272 ms 2432 KB
17.txt AC 2220 ms 256 KB
18.txt AC 2227 ms 384 KB
19.txt AC 2228 ms 256 KB
20.txt AC 2244 ms 256 KB
21.txt WA 2266 ms 1280 KB
22.txt WA 2269 ms 1280 KB
23.txt WA 2258 ms 1280 KB
24.txt WA 2320 ms 1280 KB
25.txt WA 2264 ms 1280 KB
26.txt WA 2283 ms 1280 KB
27.txt WA 2455 ms 18432 KB
28.txt AC 31 ms 256 KB
29.txt AC 41 ms 256 KB
30.txt WA 2218 ms 256 KB
31.txt AC 2220 ms 256 KB
32.txt AC 2220 ms 256 KB
33.txt AC 4 ms 256 KB
34.txt AC 2285 ms 256 KB
35.txt AC 116 ms 256 KB
36.txt AC 4 ms 256 KB
37.txt WA 2256 ms 512 KB
38.txt WA 2268 ms 512 KB
39.txt WA 2272 ms 512 KB
40.txt WA 2259 ms 512 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 5 ms 256 KB
47.txt WA 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