結果

問題 No.1653 Squarefree
ユーザー ぷらぷら
提出日時 2021-08-20 22:51:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 673 ms / 2,000 ms
コード長 1,037 bytes
コンパイル時間 2,144 ms
コンパイル使用メモリ 198,352 KB
実行使用メモリ 11,332 KB
最終ジャッジ日時 2024-04-22 09:19:14
合計ジャッジ時間 20,278 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 640 ms
11,220 KB
testcase_01 AC 12 ms
5,248 KB
testcase_02 AC 12 ms
5,376 KB
testcase_03 AC 13 ms
5,376 KB
testcase_04 AC 12 ms
5,376 KB
testcase_05 AC 12 ms
5,376 KB
testcase_06 AC 13 ms
5,376 KB
testcase_07 AC 12 ms
5,376 KB
testcase_08 AC 12 ms
5,376 KB
testcase_09 AC 12 ms
5,376 KB
testcase_10 AC 12 ms
5,376 KB
testcase_11 AC 467 ms
11,224 KB
testcase_12 AC 484 ms
11,240 KB
testcase_13 AC 612 ms
11,180 KB
testcase_14 AC 581 ms
11,236 KB
testcase_15 AC 637 ms
11,240 KB
testcase_16 AC 601 ms
11,136 KB
testcase_17 AC 587 ms
11,148 KB
testcase_18 AC 621 ms
11,216 KB
testcase_19 AC 615 ms
11,272 KB
testcase_20 AC 592 ms
11,220 KB
testcase_21 AC 638 ms
11,136 KB
testcase_22 AC 623 ms
11,220 KB
testcase_23 AC 641 ms
11,120 KB
testcase_24 AC 649 ms
11,264 KB
testcase_25 AC 669 ms
11,332 KB
testcase_26 AC 656 ms
11,068 KB
testcase_27 AC 652 ms
11,264 KB
testcase_28 AC 666 ms
11,116 KB
testcase_29 AC 630 ms
11,128 KB
testcase_30 AC 640 ms
11,104 KB
testcase_31 AC 673 ms
11,296 KB
testcase_32 AC 668 ms
11,136 KB
testcase_33 AC 626 ms
11,272 KB
testcase_34 AC 653 ms
11,212 KB
testcase_35 AC 645 ms
11,320 KB
testcase_36 AC 13 ms
5,376 KB
testcase_37 AC 12 ms
5,376 KB
testcase_38 AC 12 ms
5,376 KB
testcase_39 AC 12 ms
5,376 KB
testcase_40 AC 12 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    long long L,R;
    cin >> L >> R;
    vector<long long>tmp(R-L+1);
    for(long long j = L; j <= R; j++) {
        tmp[j-L] = j;
    }
    vector<bool>used(R-L+1);
    for(long long i = 2; i <= 1000000; i++) {
        for(long long j = (L+i-1)/i*i; j <= R; j += i) {
            int cnt = 0;
            while (tmp[j-L]%i == 0) {
                tmp[j-L] /= i;
                cnt++;
            }
            if(cnt >= 2) {
                used[j-L] = true;
            }
        }
    }
    int ans = 0;
    for(long long i = L; i <= R; i++) {
        if(!used[i-L]) {
            long long l = 1,r = 1001001001;
            while (l+1 < r) {
                long long mid = (l+r)/2;
                if(mid*mid >= tmp[i-L]) {
                    r = mid;
                }
                else {
                    l = mid;
                }
            }
            if(r*r != tmp[i-L]) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}
0