Contest Duration: - (local time) (110 minutes) Back to Home

Submission #846911

Source Code Expand

Copy
```#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

vector<ll> Primes;
set<ll> m;

P f(ll x){
P ret = P(1,1);
rep(i,Primes.size()){
ll p = Primes[i];
ll cnt = 0;
while(x%p ==0){
x /= p;
cnt ++;
}
if(cnt%3 == 1){
ret.fr *= p;
ret.sc *= p*p;
}
else if(cnt%3 == 2){
ret.fr *= p*p;
ret.sc *= p;
}
if(ret.sc > 10000000000)return P(-1,-1);
}
if(m.find(x) != m.end()){
ret.fr *= x;
ret.sc *= (ll)(sqrt((ld)x)+0.5);
x = 1;
}
if(x != 1)return P(-1,-1);
else return ret;
}

int main(){
bool prime[100010];
rep(i,100010)prime[i] = true;
for(ll i = 2 ; i < 100010 ; i ++){
if(prime[i]){
if(i < 3000)Primes.pb(i);
else {
m.insert(i*i);
}
for(ll j = i*i ; j < 100010 ; j += i){
prime[j] = false;
}
}
}
//cout << Primes.size() << endl;

int n;
ll s[100010];
scanf("%d",&n);
rep(i,n)scanf("%lld",&s[i]);

map<ll,P> MAP;
int cnt = 0;
bool t = false;
rep(i,n){
P p = f(s[i]);
if(p.fr == -1)cnt ++;
else if(p.fr == 1)t = true;
else {
if(p.fr < p.sc)MAP[p.fr].fr ++;
else MAP[p.sc].sc ++;
}
}

if(t)cnt ++;
for(map<ll,P>::iterator itr = MAP.begin() ; itr != MAP.end() ; itr++){
cnt += max ( itr->sc.fr , itr->sc.sc );
}
cout << cnt << endl;
}

```

#### Submission Info

Submission Time 2016-08-21 21:51:14+0900 D - Anticube yokozuna57 C++14 (GCC 5.4.1) 0 2264 Byte WA 839 ms 4736 KB

#### Compile Error

```./Main.cpp: In function ‘int main()’:
./Main.cpp:86:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:87:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep(i,n)scanf("%lld",&s[i]);
^
```

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1100
Status
 AC × 3
 AC × 37 WA × 14
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 719 ms 1536 KB
02.txt AC 716 ms 1536 KB
03.txt AC 715 ms 1536 KB
04.txt AC 716 ms 1536 KB
05.txt AC 716 ms 1536 KB
06.txt AC 715 ms 1536 KB
07.txt AC 714 ms 1536 KB
08.txt AC 716 ms 1536 KB
09.txt AC 716 ms 1536 KB
10.txt AC 716 ms 1536 KB
11.txt AC 777 ms 1536 KB
12.txt AC 777 ms 1536 KB
13.txt WA 767 ms 2048 KB
14.txt WA 768 ms 2048 KB
15.txt WA 767 ms 2048 KB
16.txt WA 767 ms 2048 KB
17.txt AC 839 ms 1536 KB
18.txt AC 838 ms 1536 KB
19.txt AC 838 ms 1536 KB
20.txt AC 839 ms 1536 KB
21.txt WA 780 ms 1792 KB
22.txt WA 779 ms 1792 KB
23.txt WA 809 ms 1920 KB
24.txt WA 780 ms 1792 KB
25.txt WA 781 ms 1792 KB
26.txt WA 780 ms 1792 KB
27.txt AC 807 ms 4736 KB
28.txt AC 756 ms 1536 KB
29.txt AC 768 ms 1536 KB
30.txt AC 766 ms 1536 KB
31.txt AC 771 ms 1536 KB
32.txt AC 766 ms 1536 KB
33.txt AC 7 ms 768 KB
34.txt AC 833 ms 1536 KB
35.txt AC 826 ms 1536 KB
36.txt AC 7 ms 768 KB
37.txt WA 779 ms 1536 KB
38.txt WA 781 ms 1536 KB
39.txt WA 779 ms 1536 KB
40.txt WA 779 ms 1536 KB
41.txt AC 7 ms 768 KB
42.txt AC 7 ms 768 KB
43.txt AC 7 ms 768 KB
44.txt AC 7 ms 768 KB
45.txt AC 10 ms 768 KB
46.txt AC 7 ms 768 KB
47.txt AC 7 ms 768 KB
48.txt AC 7 ms 768 KB
s1.txt AC 7 ms 768 KB
s2.txt AC 7 ms 768 KB
s3.txt AC 7 ms 768 KB