結果

問題 No.1746 Sqrt Integer Segments
ユーザー chocoruskchocorusk
提出日時 2021-11-18 00:11:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 239 ms / 2,000 ms
コード長 1,552 bytes
コンパイル時間 3,459 ms
コンパイル使用メモリ 194,732 KB
実行使用メモリ 31,740 KB
最終ジャッジ日時 2023-10-11 10:31:36
合計ジャッジ時間 8,470 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
17,088 KB
testcase_01 AC 15 ms
17,328 KB
testcase_02 AC 156 ms
27,540 KB
testcase_03 AC 79 ms
23,096 KB
testcase_04 AC 107 ms
24,924 KB
testcase_05 AC 221 ms
31,376 KB
testcase_06 AC 64 ms
21,980 KB
testcase_07 AC 31 ms
18,696 KB
testcase_08 AC 148 ms
27,512 KB
testcase_09 AC 227 ms
31,412 KB
testcase_10 AC 60 ms
21,576 KB
testcase_11 AC 204 ms
30,084 KB
testcase_12 AC 239 ms
31,520 KB
testcase_13 AC 237 ms
31,520 KB
testcase_14 AC 238 ms
31,552 KB
testcase_15 AC 231 ms
31,740 KB
testcase_16 AC 232 ms
31,520 KB
testcase_17 AC 133 ms
26,188 KB
testcase_18 AC 43 ms
18,596 KB
testcase_19 AC 43 ms
18,588 KB
testcase_20 AC 43 ms
18,756 KB
testcase_21 AC 50 ms
18,240 KB
testcase_22 AC 50 ms
18,400 KB
testcase_23 AC 34 ms
17,856 KB
testcase_24 AC 85 ms
19,012 KB
testcase_25 AC 85 ms
19,096 KB
testcase_26 AC 85 ms
19,028 KB
testcase_27 AC 100 ms
19,028 KB
testcase_28 AC 100 ms
19,044 KB
testcase_29 AC 100 ms
19,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint998244353;
const int MAX=1000010;
int pf[MAX];
void sieve(){
    for(int i=2; i<MAX; i++) pf[i]=i;
    for(int i=2; i<MAX; i++){
        if(pf[i]==i){
            for(int j=(i<<1); j<MAX; j+=i){
                pf[j]=i;
            }
        }
    }
}
using ull=unsigned long long;
mt19937_64 mt(334);
int n;
int a[200020];
ull x[MAX];
ull v[200020], vs[200020];
int main()
{
    cin>>n;
    for(int i=0; i<n; i++) cin>>a[i];
    sieve();
    for(int i=2; i<MAX; i++){
        if(pf[i]==i) x[i]=mt();
    }
    for(int i=0; i<n; i++){
        if(a[i]==1) continue;
        while(pf[a[i]]!=a[i]){
            v[i]^=x[pf[a[i]]];
            a[i]/=pf[a[i]];
        }
        v[i]^=x[a[i]];
    }
    for(int i=0; i<n; i++){
        vs[i+1]=(vs[i]^v[i]);
    }
    map<ull, ll> mp;
    for(int i=0; i<=n; i++) mp[vs[i]]++;
    ll ans=0;
    for(auto p:mp){
        ans+=p.second*(p.second-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}
0