結果

問題 No.1746 Sqrt Integer Segments
ユーザー 沙耶花沙耶花
提出日時 2021-11-18 06:52:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 315 ms / 2,000 ms
コード長 1,104 bytes
コンパイル時間 2,120 ms
コンパイル使用メモリ 211,180 KB
実行使用メモリ 31,140 KB
最終ジャッジ日時 2023-10-11 10:39:29
合計ジャッジ時間 8,594 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
26,532 KB
testcase_01 AC 50 ms
26,544 KB
testcase_02 AC 222 ms
27,708 KB
testcase_03 AC 130 ms
26,468 KB
testcase_04 AC 159 ms
26,496 KB
testcase_05 AC 306 ms
31,028 KB
testcase_06 AC 113 ms
26,452 KB
testcase_07 AC 66 ms
26,400 KB
testcase_08 AC 211 ms
27,668 KB
testcase_09 AC 299 ms
31,016 KB
testcase_10 AC 105 ms
26,528 KB
testcase_11 AC 276 ms
29,892 KB
testcase_12 AC 315 ms
31,140 KB
testcase_13 AC 307 ms
31,136 KB
testcase_14 AC 305 ms
31,008 KB
testcase_15 AC 310 ms
31,092 KB
testcase_16 AC 312 ms
31,076 KB
testcase_17 AC 179 ms
26,492 KB
testcase_18 AC 79 ms
26,272 KB
testcase_19 AC 80 ms
26,564 KB
testcase_20 AC 80 ms
26,468 KB
testcase_21 AC 77 ms
26,264 KB
testcase_22 AC 78 ms
26,332 KB
testcase_23 AC 64 ms
26,352 KB
testcase_24 AC 107 ms
26,424 KB
testcase_25 AC 105 ms
26,400 KB
testcase_26 AC 109 ms
26,272 KB
testcase_27 AC 116 ms
26,284 KB
testcase_28 AC 115 ms
26,492 KB
testcase_29 AC 116 ms
26,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001

unsigned long xor128() {
	static unsigned long x=123456789, y=362436069, z=521288629, w=88675123;
	unsigned long t=(x^(x<<11));
	x=y; y=z; z=w;
	return (w=(w^(w>>19))^(t^(t>>8)));
}

vector<long long> get(){
	vector<long long> h(1000001,0);
	rep(i,h.size())h[i] = xor128();
	
	vector<long long> a(1000001,0);
	vector<bool> f(1000001,true);
	for(int i=2;i<a.size();i++){
		if(!f[i])continue;
		long long t = i;
		while(t<a.size()){
			for(long long j=t;j<a.size();j+=t){
				f[j] = false;
				a[j] ^= h[i];
			}
			t *= i;
		}
	}
	return a;
}

int main(){
	auto a = get();
	auto b = get();
	
	
	int n;
	cin>>n;
	
	pair<long long,long long> sum(0,0);
	long long ans = 0LL;
	map<pair<long long,long long>,long long> mp;
	mp[sum] ++;
	
	rep(i,n){
		long long x;
		cin>>x;
		sum.first ^= a[x];
		sum.second ^= b[x];
		
		ans += mp[sum];
		mp[sum]++;
	}
	
	cout<<ans<<endl;
	
	
	
	return 0;
}
0