結果

問題 No.1653 Squarefree
ユーザー pockynypockyny
提出日時 2021-08-20 22:14:24
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 249 ms / 2,000 ms
コード長 968 bytes
コンパイル時間 894 ms
コンパイル使用メモリ 83,908 KB
実行使用メモリ 13,032 KB
最終ジャッジ日時 2023-08-04 11:30:02
合計ジャッジ時間 8,788 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 242 ms
11,556 KB
testcase_01 AC 12 ms
4,376 KB
testcase_02 AC 12 ms
4,380 KB
testcase_03 AC 12 ms
4,388 KB
testcase_04 AC 12 ms
4,376 KB
testcase_05 AC 12 ms
4,384 KB
testcase_06 AC 12 ms
4,380 KB
testcase_07 AC 12 ms
4,380 KB
testcase_08 AC 12 ms
4,380 KB
testcase_09 AC 12 ms
4,376 KB
testcase_10 AC 12 ms
4,380 KB
testcase_11 AC 204 ms
11,888 KB
testcase_12 AC 205 ms
11,424 KB
testcase_13 AC 241 ms
11,400 KB
testcase_14 AC 244 ms
12,380 KB
testcase_15 AC 238 ms
11,548 KB
testcase_16 AC 235 ms
11,332 KB
testcase_17 AC 233 ms
12,156 KB
testcase_18 AC 244 ms
13,032 KB
testcase_19 AC 229 ms
11,840 KB
testcase_20 AC 239 ms
12,256 KB
testcase_21 AC 244 ms
12,160 KB
testcase_22 AC 237 ms
11,620 KB
testcase_23 AC 225 ms
12,208 KB
testcase_24 AC 232 ms
12,852 KB
testcase_25 AC 232 ms
12,404 KB
testcase_26 AC 241 ms
11,844 KB
testcase_27 AC 249 ms
11,976 KB
testcase_28 AC 235 ms
11,968 KB
testcase_29 AC 233 ms
11,476 KB
testcase_30 AC 231 ms
11,500 KB
testcase_31 AC 235 ms
13,000 KB
testcase_32 AC 233 ms
12,184 KB
testcase_33 AC 230 ms
12,216 KB
testcase_34 AC 237 ms
12,596 KB
testcase_35 AC 232 ms
11,844 KB
testcase_36 AC 12 ms
4,376 KB
testcase_37 AC 12 ms
4,380 KB
testcase_38 AC 13 ms
4,380 KB
testcase_39 AC 12 ms
4,376 KB
testcase_40 AC 13 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
typedef long long ll;
ll p[1000010];
int main(){
    ll i,j,l,r; cin >> l >> r;
    vector<ll> v;
    for(i=l;i<=r;i++) v.push_back(i); //v[i] = l + i
    for(i=2;i<=1000000;i++){
        ll ll = (l + i - 1)/i*i; //ll,ll + i,ll + 2*i...
        for(j=ll;j<=r;j+=i){
            if(v[j - l]!=0 && v[j - l]%i==0){
                int cnt = 0;
                while(v[j - l]%i==0){
                    //cout << v[j - l] << " " << i << endl;
                    v[j - l] /= i; cnt++;
                }
                if(cnt>=2) v[j - l] = 0;
            }
        }
    }
    /*for(i=l;i<=r;i++) cout << i << " ";
    cout << endl;
    for(ll x:v) cout << x << " ";
    cout << endl;*/
    int cnt = v.size();
    for(ll x:v){
        if(x==1) continue;
        if(x==0) cnt--;
        else{
            ll y = sqrt(x);
            if(x==y*y) cnt--;
        } 
    }
    cout << cnt << endl;
}
0