結果

問題 No.1653 Squarefree
ユーザー monnumonnu
提出日時 2021-08-29 02:16:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 894 bytes
コンパイル時間 3,904 ms
コンパイル使用メモリ 230,564 KB
実行使用メモリ 15,164 KB
最終ジャッジ日時 2024-05-01 19:29:40
合計ジャッジ時間 19,566 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 552 ms
15,092 KB
testcase_01 AC 4 ms
5,248 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 4 ms
5,376 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 418 ms
14,928 KB
testcase_12 AC 395 ms
14,944 KB
testcase_13 WA -
testcase_14 AC 540 ms
14,804 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 501 ms
14,976 KB
testcase_19 AC 479 ms
14,920 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 514 ms
14,844 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 512 ms
14,772 KB
testcase_27 AC 477 ms
14,976 KB
testcase_28 AC 564 ms
14,848 KB
testcase_29 AC 494 ms
14,976 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 4 ms
5,376 KB
testcase_37 AC 4 ms
5,376 KB
testcase_38 AC 4 ms
5,376 KB
testcase_39 AC 4 ms
5,376 KB
testcase_40 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 2000000
#define MOD 1000000007
#define INF 1000000000

int main(){
  ll L,R;
  cin>>L>>R;
  vector<int> cnt(R-L+1,1);
  vector<ll> A(R-L+1);
  for(ll i=L;i<=R;i++){
    A[i-L]=i;
  }
  for(ll i=2;i<=100000;i++){
    ll x=i*i;
    for(ll j=((L-1)/x+1)*x;j<=R;j+=x){
      cnt[j-L]=0;
    }
    for(ll j=((L-1)/i+1)*i;j<=R;j+=i){
      while(A[j-L]%i==0){
        A[j-L]/=i;
      }
    }
  }
  for(ll i=L;i<=R;i++){
    ll left=0;
    ll right=1000000001;
    while(left+1<right){
      ll x=(left+right)/2;
      if(x*x<=A[i-L]){
        left=x;
      }else{
        right=x;
      }
    }
    if(left*left==A[i-L]&&left>1){
      cnt[i-L]=0;
    }
  }

  int ans=0;
  for(ll i=L;i<=R;i++){
    ans+=cnt[i-L];
  }
  cout<<ans<<'\n';
}
0