結果

問題 No.1746 Sqrt Integer Segments
ユーザー ぷらぷら
提出日時 2021-11-18 00:40:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,530 bytes
コンパイル時間 3,163 ms
コンパイル使用メモリ 213,252 KB
実行使用メモリ 27,932 KB
最終ジャッジ日時 2023-08-25 22:16:52
合計ジャッジ時間 7,230 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
14,728 KB
testcase_01 AC 12 ms
14,732 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 42 ms
16,948 KB
testcase_19 AC 43 ms
17,116 KB
testcase_20 AC 43 ms
17,036 KB
testcase_21 AC 50 ms
15,992 KB
testcase_22 AC 50 ms
16,248 KB
testcase_23 AC 31 ms
15,688 KB
testcase_24 AC 90 ms
17,060 KB
testcase_25 AC 90 ms
17,080 KB
testcase_26 AC 90 ms
17,072 KB
testcase_27 AC 104 ms
17,076 KB
testcase_28 AC 105 ms
17,040 KB
testcase_29 AC 105 ms
17,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

random_device rng;

struct primenumber {
    vector<int> spf;
    vector<long long>pura;
    primenumber(int N) {
        init(N);
    }
    void init(int N) {
        spf.assign(N+1,0);
        pura.assign(N+1,0);
        for(int i = 0; i <= N; i++) {
            spf[i] = i;
        }
        for(int i = 2; i*i <= N; i++) {
            if(spf[i] == i) {
                pura[i] = rng()%1001001001001001001+rng()%1001001001001001001;
                for(int j = i*i; j <= N; j += i) {
                    if(spf[j] == j) {
                        spf[j] = i;
                    }
                }
            }
        }
    }
    bool is_prime(long long n) {
        bool flag = true;
        if(n == 1) {
            flag = false;
        }
        for(long long i = 2; i*i <= n; i++) {
            if(n%i == 0) {
                flag = false;
            }
        }
        return flag;
    }
    long long get(int n) {
        long long m = 0;
        while(n != 1) {
            m ^= pura[spf[n]];
            n /= spf[n];
        }
        return m;
    }
};

int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    vector<long long>b(n+1);
    primenumber zz(1000001);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        b[i+1] = b[i]^zz.get(a[i]);
    }
    sort(b.begin(),b.end());
    long long ans = 0;
    map<long long,int>tmp;
    for(int i = 0; i < b.size(); i++) {
        ans += tmp[b[i]];
        tmp[b[i]]++;
    }
    cout << ans << endl;
}
0