結果

問題 No.1746 Sqrt Integer Segments
ユーザー ぷらぷら
提出日時 2021-11-18 00:42:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,485 bytes
コンパイル時間 2,261 ms
コンパイル使用メモリ 214,388 KB
実行使用メモリ 27,916 KB
最終ジャッジ日時 2023-08-25 22:19:34
合計ジャッジ時間 7,727 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
14,624 KB
testcase_01 AC 11 ms
14,632 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 44 ms
17,304 KB
testcase_19 AC 44 ms
17,144 KB
testcase_20 AC 45 ms
17,096 KB
testcase_21 AC 52 ms
15,720 KB
testcase_22 AC 52 ms
15,712 KB
testcase_23 AC 32 ms
15,220 KB
testcase_24 AC 91 ms
17,020 KB
testcase_25 AC 91 ms
17,052 KB
testcase_26 AC 92 ms
17,080 KB
testcase_27 AC 106 ms
17,300 KB
testcase_28 AC 106 ms
17,108 KB
testcase_29 AC 107 ms
17,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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] = rand()%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