結果

問題 No.1653 Squarefree
ユーザー HaaHaa
提出日時 2021-08-20 22:47:47
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 966 bytes
コンパイル時間 1,705 ms
コンパイル使用メモリ 164,892 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-22 09:12:26
合計ジャッジ時間 8,982 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 209 ms
11,008 KB
testcase_01 AC 24 ms
5,376 KB
testcase_02 AC 24 ms
5,376 KB
testcase_03 AC 23 ms
5,376 KB
testcase_04 AC 24 ms
5,376 KB
testcase_05 AC 23 ms
5,376 KB
testcase_06 AC 23 ms
5,376 KB
testcase_07 AC 23 ms
5,376 KB
testcase_08 AC 24 ms
5,376 KB
testcase_09 AC 24 ms
5,376 KB
testcase_10 AC 23 ms
5,376 KB
testcase_11 AC 207 ms
11,008 KB
testcase_12 AC 205 ms
11,008 KB
testcase_13 AC 208 ms
11,136 KB
testcase_14 AC 208 ms
10,880 KB
testcase_15 AC 209 ms
11,008 KB
testcase_16 AC 208 ms
11,136 KB
testcase_17 AC 208 ms
11,008 KB
testcase_18 AC 208 ms
11,136 KB
testcase_19 AC 209 ms
11,008 KB
testcase_20 AC 210 ms
11,008 KB
testcase_21 AC 209 ms
11,008 KB
testcase_22 AC 209 ms
11,008 KB
testcase_23 AC 209 ms
11,008 KB
testcase_24 AC 209 ms
11,136 KB
testcase_25 AC 209 ms
11,136 KB
testcase_26 AC 207 ms
10,880 KB
testcase_27 AC 208 ms
11,008 KB
testcase_28 AC 208 ms
11,008 KB
testcase_29 AC 208 ms
11,008 KB
testcase_30 AC 208 ms
11,008 KB
testcase_31 AC 212 ms
11,136 KB
testcase_32 AC 211 ms
11,008 KB
testcase_33 AC 208 ms
11,136 KB
testcase_34 AC 209 ms
11,008 KB
testcase_35 AC 214 ms
11,008 KB
testcase_36 AC 23 ms
5,376 KB
testcase_37 AC 24 ms
5,376 KB
testcase_38 AC 23 ms
5,376 KB
testcase_39 AC 24 ms
5,376 KB
testcase_40 AC 24 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
template<typename T> bool chmax(T &x, const T &y) {return (x<y)?(x=y,true):false;};
template<typename T> bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;};
constexpr ll MOD=998244353;
constexpr ll INF=2e18;

int main() {
    ll l, r; cin >> l >> r;
    VI f(r-l+1,0);
    ll rt;
    for(ll i=1;i<=1000000;i++){
        ll s=(l/i)*i;
        if(s<l) s+=i;
        for(ll j=s;j<=r;j+=i){
            rt=sqrt(j/i);
            if(rt!=1&&rt*rt==j/i)
                f[j-l]=1;
        }
        if(i==1) continue;
        ll k=i*i;
        s=(l/k)*k;
        if(s<l) s+=k;
        for(ll j=s;j<=r;j+=k){
            f[j-l]=1;
        }
    }
    int ans=0;
    for(ll i=l;i<=r;i++)
        ans+=!f[i-l];
    cout << ans << endl;
    return 0;
}
0