結果

問題 No.1514 Squared Matching
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-18 22:17:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 883 bytes
コンパイル時間 2,422 ms
コンパイル使用メモリ 200,724 KB
実行使用メモリ 393,512 KB
最終ジャッジ日時 2023-09-08 16:03:47
合計ジャッジ時間 9,389 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 175 ms
393,512 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

vector<ll> prime(8001, 1), odd(5e7+1);

void erat(long long N){
    prime[0] = 0;
    prime[1] = 0;
    iota(odd.begin(), odd.end(), 0);
    for (long long i=2; i*i<=N; i++){
        if (prime[i]){
            for (long long j=i*2; j <= 8000; j+=i){
                prime[j] = 0;
            }
            ll q=1;
            while(i*i<=N/q){
                q*=i*i;
                for (ll j=q; j<=N; j+=q){
                    odd[j] /= (i*i);
                }
            }
        }
    }
}

ll isqrt(ll s){
    ll l=0, r=3e9, c;
    while(r-l>1){
        c = (l+r)/2;
        if (c*c <= s) l = c;
        else r = c;
    }
    return l;
}

int main(){

    ll N, ans=0;
    cin >> N;
    erat(N);
    for (ll i=1; i<=N; i++){
        ans += isqrt(N/odd[i]);
    }

    cout << ans << endl;

    return 0;
}
0