結果

問題 No.1653 Squarefree
ユーザー nawawannawawan
提出日時 2021-08-20 23:26:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,229 bytes
コンパイル時間 2,146 ms
コンパイル使用メモリ 200,948 KB
実行使用メモリ 28,964 KB
最終ジャッジ日時 2024-04-22 07:59:05
合計ジャッジ時間 9,167 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 200 ms
28,220 KB
testcase_01 AC 13 ms
7,092 KB
testcase_02 AC 12 ms
7,224 KB
testcase_03 AC 12 ms
6,956 KB
testcase_04 AC 14 ms
6,956 KB
testcase_05 AC 13 ms
6,952 KB
testcase_06 AC 14 ms
7,100 KB
testcase_07 AC 14 ms
7,104 KB
testcase_08 AC 12 ms
7,248 KB
testcase_09 AC 13 ms
7,076 KB
testcase_10 AC 13 ms
7,168 KB
testcase_11 AC 188 ms
28,424 KB
testcase_12 AC 193 ms
27,724 KB
testcase_13 AC 197 ms
27,408 KB
testcase_14 AC 201 ms
27,948 KB
testcase_15 AC 208 ms
28,848 KB
testcase_16 AC 194 ms
27,508 KB
testcase_17 AC 206 ms
28,656 KB
testcase_18 AC 205 ms
27,400 KB
testcase_19 AC 202 ms
28,108 KB
testcase_20 AC 203 ms
28,224 KB
testcase_21 AC 203 ms
27,532 KB
testcase_22 AC 198 ms
27,376 KB
testcase_23 AC 201 ms
27,816 KB
testcase_24 WA -
testcase_25 AC 194 ms
27,836 KB
testcase_26 AC 196 ms
28,560 KB
testcase_27 AC 200 ms
27,396 KB
testcase_28 AC 194 ms
27,340 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 203 ms
27,320 KB
testcase_32 AC 204 ms
27,232 KB
testcase_33 AC 201 ms
27,956 KB
testcase_34 AC 212 ms
27,608 KB
testcase_35 AC 208 ms
27,616 KB
testcase_36 AC 13 ms
7,144 KB
testcase_37 AC 13 ms
7,240 KB
testcase_38 AC 12 ms
7,112 KB
testcase_39 AC 12 ms
7,020 KB
testcase_40 AC 14 ms
7,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    long long L, R;
    cin >> L >> R;
    vector<int> fac(1000010);
    iota(fac.begin(), fac.end(), 0);
    for(int i = 2; i < 1000010; i++){
        if(fac[i] != i) continue;
        for(int j = i * 2; j < 1000010; j += i){
            fac[j] = i;
        }
    }
    vector<long long> t(R - L + 1);
    vector<long long> temp;
    vector<int> num(R - L + 1);
    iota(t.begin(), t.end(), L);
    for(int i = 2; i <= 1000010; i++){
        if(fac[i] != i) continue;
        for(long long j = (L + i - 1) / i * i; j <= R; j += i){
            int cnt = 0;
            while(t[j - L] % i == 0){
                t[j - L] /= i;
                cnt++;
            }
            if(cnt > 1) num[j - L] = -1;
        }
    }
    for(int i = 0; i < R - L + 1; i++){
        if(num[i] == 0) temp.push_back(L + i);
    }
    int ans = temp.size();
    for(int i = 0; i < (int)temp.size(); i++){
        long long ub = 1000000000, lb = 0;
        while(ub - lb > 1){
            long long mid = (ub + lb) / 2;
            if(mid * mid >= t[temp[i] - L]) ub = mid;
            else lb = mid;
        }
        if(ub != 1 && ub * ub == t[i]) ans--;
    }
    cout << ans << endl;
}
0