結果
| 問題 |
No.1746 Sqrt Integer Segments
|
| ユーザー |
|
| 提出日時 | 2021-11-18 00:58:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 277 ms / 2,000 ms |
| コード長 | 813 bytes |
| コンパイル時間 | 1,060 ms |
| コンパイル使用メモリ | 102,436 KB |
| 実行使用メモリ | 30,248 KB |
| 最終ジャッジ日時 | 2024-09-13 09:24:15 |
| 合計ジャッジ時間 | 6,484 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 28 |
コンパイルメッセージ
main.cpp:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
13 | main()
| ^~~~
ソースコード
#include<iostream>
#include<vector>
#include<array>
#include<random>
#include<map>
using namespace std;
const int T=3;
using dat=array<unsigned int,T>;
bool isp[1<<20];
vector<int>ps;
unsigned int hs[T][1<<20];
int N,A[2<<17];
main()
{
for(int i=2;i<1<<20;i++)if(!isp[i])
{
ps.push_back(i);
for(int j=i+i;j<1<<20;j+=i)isp[j]=true;
}
mt19937 rng(114514);
for(int p:ps)
{
for(int i=0;i<T;i++)hs[i][p]=rng();
}
cin>>N;
map<dat,int>cnt;
long ans=0;
dat now={};
cnt[now]=1;
for(int i=0;i<N;i++)
{
cin>>A[i];
for(int j=0;ps[j]*ps[j]<=A[i];j++)if(A[i]%ps[j]==0)
{
int c=0;
while(A[i]%ps[j]==0)A[i]/=ps[j],c++;
if(c%2)
{
for(int k=0;k<T;k++)now[k]^=hs[k][ps[j]];
}
}
if(A[i]>1)
{
for(int k=0;k<T;k++)now[k]^=hs[k][A[i]];
}
ans+=cnt[now]++;
}
cout<<ans<<endl;
}