結果

問題 No.1653 Squarefree
ユーザー たたき@競プロたたき@競プロ
提出日時 2023-08-30 02:30:42
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 652 ms / 2,000 ms
コード長 934 bytes
コンパイル時間 5,201 ms
コンパイル使用メモリ 307,252 KB
実行使用メモリ 18,916 KB
最終ジャッジ日時 2023-08-30 02:31:07
合計ジャッジ時間 24,180 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 565 ms
18,748 KB
testcase_01 AC 12 ms
4,376 KB
testcase_02 AC 12 ms
4,376 KB
testcase_03 AC 12 ms
4,376 KB
testcase_04 AC 12 ms
4,376 KB
testcase_05 AC 12 ms
4,376 KB
testcase_06 AC 12 ms
4,380 KB
testcase_07 AC 12 ms
4,376 KB
testcase_08 AC 12 ms
4,376 KB
testcase_09 AC 12 ms
4,380 KB
testcase_10 AC 13 ms
4,376 KB
testcase_11 AC 526 ms
18,736 KB
testcase_12 AC 489 ms
18,800 KB
testcase_13 AC 611 ms
18,532 KB
testcase_14 AC 592 ms
18,484 KB
testcase_15 AC 616 ms
18,788 KB
testcase_16 AC 579 ms
18,796 KB
testcase_17 AC 651 ms
18,844 KB
testcase_18 AC 580 ms
18,752 KB
testcase_19 AC 594 ms
18,576 KB
testcase_20 AC 594 ms
18,720 KB
testcase_21 AC 593 ms
18,740 KB
testcase_22 AC 578 ms
18,872 KB
testcase_23 AC 633 ms
18,536 KB
testcase_24 AC 586 ms
18,596 KB
testcase_25 AC 610 ms
18,800 KB
testcase_26 AC 609 ms
18,644 KB
testcase_27 AC 652 ms
18,872 KB
testcase_28 AC 627 ms
18,524 KB
testcase_29 AC 626 ms
18,916 KB
testcase_30 AC 627 ms
18,700 KB
testcase_31 AC 590 ms
18,592 KB
testcase_32 AC 584 ms
18,732 KB
testcase_33 AC 568 ms
18,800 KB
testcase_34 AC 604 ms
18,916 KB
testcase_35 AC 590 ms
18,596 KB
testcase_36 AC 12 ms
4,380 KB
testcase_37 AC 12 ms
4,380 KB
testcase_38 AC 12 ms
4,380 KB
testcase_39 AC 12 ms
4,376 KB
testcase_40 AC 12 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint998244353; //1000000007;
using ll=long long;
using pp=pair<int,int>;
#define sr string 
#define vc vector
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
ll root(ll a){
  ll wa=1,ac=1e9;
  while(ac-wa>1){
    ll x=(ac+wa)/2;
    if(x*x>=a)ac=x;
    else wa=x;
  }
  return ac;
}
int main(){
  ll l,r;cin>>l>>r;
  ll n=r-l+1;
  vc<ll>v(n),ch(n,0); for(ll i=0;i<n;i++)v[i]=i+l;
  for(ll i=2;i<=1e6;i++)for(ll j=(l+i-1)/i*i;j<=r;j+=i){
    int t=0;
    while(v[j-l]%i==0)v[j-l]/=i,t++;
    if(t>1)ch[j-l]=1;
  }
  rep(i,n)if(!ch[i]){
    ll x=root(v[i]);
    if(x*x==v[i])ch[i]=1;
  }
  int ans=0;
  rep(i,n)ans+=ch[i];
  //cout<<root(1000000)<<"\n";
  ans=n-ans;
  cout<<ans;
}
0