結果
| 問題 |
No.1653 Squarefree
|
| コンテスト | |
| ユーザー |
たたき@競プロ
|
| 提出日時 | 2023-08-30 02:30:42 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 465 ms / 2,000 ms |
| コード長 | 934 bytes |
| コンパイル時間 | 5,222 ms |
| コンパイル使用メモリ | 309,404 KB |
| 実行使用メモリ | 19,116 KB |
| 最終ジャッジ日時 | 2024-12-31 08:16:46 |
| 合計ジャッジ時間 | 18,440 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#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;
}
たたき@競プロ