結果

問題 No.1653 Squarefree
ユーザー nawawannawawan
提出日時 2021-08-20 23:25:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,229 bytes
コンパイル時間 2,279 ms
コンパイル使用メモリ 201,076 KB
実行使用メモリ 28,740 KB
最終ジャッジ日時 2024-04-22 07:56:51
合計ジャッジ時間 10,415 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 14 ms
7,296 KB
testcase_02 AC 13 ms
7,168 KB
testcase_03 AC 14 ms
7,168 KB
testcase_04 AC 13 ms
7,072 KB
testcase_05 AC 14 ms
7,152 KB
testcase_06 AC 14 ms
7,168 KB
testcase_07 AC 14 ms
7,260 KB
testcase_08 AC 14 ms
7,076 KB
testcase_09 AC 14 ms
7,192 KB
testcase_10 AC 15 ms
7,040 KB
testcase_11 AC 235 ms
27,488 KB
testcase_12 AC 220 ms
27,356 KB
testcase_13 AC 258 ms
27,152 KB
testcase_14 AC 241 ms
27,120 KB
testcase_15 AC 239 ms
27,228 KB
testcase_16 AC 232 ms
27,296 KB
testcase_17 AC 234 ms
27,304 KB
testcase_18 AC 234 ms
27,348 KB
testcase_19 AC 254 ms
27,284 KB
testcase_20 AC 247 ms
27,356 KB
testcase_21 AC 230 ms
27,352 KB
testcase_22 AC 244 ms
27,228 KB
testcase_23 AC 224 ms
27,104 KB
testcase_24 WA -
testcase_25 AC 232 ms
27,280 KB
testcase_26 AC 227 ms
27,380 KB
testcase_27 AC 230 ms
27,220 KB
testcase_28 AC 232 ms
27,260 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 235 ms
27,320 KB
testcase_32 AC 233 ms
27,212 KB
testcase_33 AC 243 ms
27,156 KB
testcase_34 AC 246 ms
27,340 KB
testcase_35 AC 243 ms
27,312 KB
testcase_36 AC 14 ms
7,168 KB
testcase_37 WA -
testcase_38 AC 14 ms
7,020 KB
testcase_39 AC 14 ms
7,092 KB
testcase_40 AC 16 ms
7,040 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