結果

問題 No.1653 Squarefree
ユーザー SSRSSSRS
提出日時 2021-08-20 23:09:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 645 bytes
コンパイル時間 1,567 ms
コンパイル使用メモリ 167,564 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-04 11:43:39
合計ジャッジ時間 5,300 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
4,380 KB
testcase_01 AC 50 ms
4,380 KB
testcase_02 AC 50 ms
4,376 KB
testcase_03 AC 52 ms
4,376 KB
testcase_04 AC 50 ms
4,376 KB
testcase_05 AC 50 ms
4,376 KB
testcase_06 AC 50 ms
4,376 KB
testcase_07 AC 50 ms
4,380 KB
testcase_08 AC 50 ms
4,376 KB
testcase_09 AC 50 ms
4,376 KB
testcase_10 AC 50 ms
4,376 KB
testcase_11 AC 58 ms
4,380 KB
testcase_12 AC 58 ms
4,376 KB
testcase_13 AC 55 ms
4,376 KB
testcase_14 AC 54 ms
4,376 KB
testcase_15 AC 55 ms
4,376 KB
testcase_16 AC 55 ms
4,380 KB
testcase_17 AC 55 ms
4,380 KB
testcase_18 AC 55 ms
4,380 KB
testcase_19 AC 55 ms
4,376 KB
testcase_20 AC 55 ms
4,380 KB
testcase_21 AC 55 ms
4,376 KB
testcase_22 AC 55 ms
4,380 KB
testcase_23 AC 55 ms
4,380 KB
testcase_24 AC 54 ms
4,376 KB
testcase_25 AC 55 ms
4,380 KB
testcase_26 AC 55 ms
4,376 KB
testcase_27 AC 54 ms
4,376 KB
testcase_28 AC 55 ms
4,380 KB
testcase_29 AC 55 ms
4,376 KB
testcase_30 AC 55 ms
4,376 KB
testcase_31 AC 55 ms
4,380 KB
testcase_32 AC 55 ms
4,376 KB
testcase_33 AC 54 ms
4,376 KB
testcase_34 AC 54 ms
4,380 KB
testcase_35 AC 55 ms
4,380 KB
testcase_36 AC 51 ms
4,380 KB
testcase_37 AC 52 ms
4,380 KB
testcase_38 AC 52 ms
4,380 KB
testcase_39 AC 52 ms
4,376 KB
testcase_40 AC 52 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  long long L, R;
  cin >> L >> R;
  vector<bool> ok(R - L + 1, true);
  for (long long i = 2; i <= 2000000; i++){
    long long m = i * i;
    for (long long j = (L + m - 1) / m * m; j <= R; j += m){
      ok[j - L] = false;
    }
  }
  for (int j = 1; j <= 2000000; j++){
    long long a = sqrt(L / j);
    while (true){
      if (a * a * j > R){
        break;
      }
      if (a >= 2 && a * a * j >= L){
        ok[a * a * j - L] = false;
      }
      a++;
    }
  }
  int ans = 0;
  for (int i = 0; i <= R - L; i++){
    if (ok[i]){
      ans++;
    }
  }
  cout << ans << endl;
}
0