結果

問題 No.1746 Sqrt Integer Segments
ユーザー kotatsugamekotatsugame
提出日時 2021-11-18 00:58:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 286 ms / 2,000 ms
コード長 813 bytes
コンパイル時間 927 ms
コンパイル使用メモリ 96,516 KB
実行使用メモリ 30,196 KB
最終ジャッジ日時 2023-10-11 10:38:04
合計ジャッジ時間 6,659 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
16,840 KB
testcase_01 AC 13 ms
16,792 KB
testcase_02 AC 193 ms
26,184 KB
testcase_03 AC 99 ms
21,980 KB
testcase_04 AC 139 ms
23,916 KB
testcase_05 AC 285 ms
29,816 KB
testcase_06 AC 83 ms
21,048 KB
testcase_07 AC 33 ms
18,256 KB
testcase_08 AC 192 ms
26,192 KB
testcase_09 AC 286 ms
29,856 KB
testcase_10 AC 75 ms
20,704 KB
testcase_11 AC 249 ms
28,548 KB
testcase_12 AC 285 ms
30,132 KB
testcase_13 AC 275 ms
29,964 KB
testcase_14 AC 274 ms
30,196 KB
testcase_15 AC 276 ms
30,024 KB
testcase_16 AC 280 ms
30,024 KB
testcase_17 AC 164 ms
24,776 KB
testcase_18 AC 43 ms
17,720 KB
testcase_19 AC 43 ms
17,616 KB
testcase_20 AC 43 ms
17,616 KB
testcase_21 AC 63 ms
17,228 KB
testcase_22 AC 63 ms
17,188 KB
testcase_23 AC 38 ms
16,940 KB
testcase_24 AC 115 ms
17,676 KB
testcase_25 AC 114 ms
17,892 KB
testcase_26 AC 114 ms
17,792 KB
testcase_27 AC 113 ms
17,672 KB
testcase_28 AC 113 ms
17,896 KB
testcase_29 AC 112 ms
17,588 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:13:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   13 | main()
      | ^~~~

ソースコード

diff #

#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;
}
0