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

Submission #847062

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;
set<ll> m2;

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;
}
else if(m2.find(x) != m2.end()){
ret.fr *= x;
ret.sc *= x;
if(ret.sc > 10000000000)return P(-1,-1);
ret.sc *= x;
}
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);
m2.insert(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:56:24+0900 D - Anticube yokozuna57 C++14 (GCC 5.4.1) 0 2427 Byte WA 854 ms 5248 KB

#### Compile Error

```./Main.cpp: In function ‘int main()’:
./Main.cpp:94:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:95: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 732 ms 2048 KB
02.txt AC 735 ms 2048 KB
03.txt AC 733 ms 2048 KB
04.txt AC 732 ms 2048 KB
05.txt AC 732 ms 2048 KB
06.txt AC 732 ms 2048 KB
07.txt AC 734 ms 2048 KB
08.txt AC 736 ms 2048 KB
09.txt AC 733 ms 2048 KB
10.txt AC 735 ms 2048 KB
11.txt AC 800 ms 1920 KB
12.txt AC 799 ms 1920 KB
13.txt WA 784 ms 2432 KB
14.txt WA 785 ms 2432 KB
15.txt WA 787 ms 2432 KB
16.txt WA 786 ms 2432 KB
17.txt AC 840 ms 2048 KB
18.txt AC 842 ms 2048 KB
19.txt AC 854 ms 2048 KB
20.txt AC 840 ms 2048 KB
21.txt WA 800 ms 2176 KB
22.txt WA 817 ms 2176 KB
23.txt WA 797 ms 2176 KB
24.txt WA 796 ms 2176 KB
25.txt WA 795 ms 2176 KB
26.txt WA 795 ms 2176 KB
27.txt AC 824 ms 5248 KB
28.txt AC 760 ms 1920 KB
29.txt AC 769 ms 1920 KB
30.txt AC 774 ms 1920 KB
31.txt AC 772 ms 1920 KB
32.txt AC 775 ms 1920 KB
33.txt AC 10 ms 1152 KB
34.txt AC 840 ms 1920 KB
35.txt AC 838 ms 1920 KB
36.txt AC 10 ms 1152 KB
37.txt WA 799 ms 2048 KB
38.txt WA 800 ms 2048 KB
39.txt WA 801 ms 2048 KB
40.txt WA 798 ms 2048 KB
41.txt AC 10 ms 1152 KB
42.txt AC 10 ms 1152 KB
43.txt AC 10 ms 1152 KB
44.txt AC 10 ms 1152 KB
45.txt AC 10 ms 1152 KB
46.txt AC 10 ms 1152 KB
47.txt AC 10 ms 1152 KB
48.txt AC 10 ms 1152 KB
s1.txt AC 10 ms 1152 KB
s2.txt AC 10 ms 1152 KB
s3.txt AC 10 ms 1152 KB