結果

問題 No.1514 Squared Matching
ユーザー rianoriano
提出日時 2021-05-21 21:58:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 711 ms / 4,000 ms
コード長 690 bytes
コンパイル時間 1,510 ms
コンパイル使用メモリ 163,948 KB
実行使用メモリ 394,264 KB
最終ジャッジ日時 2024-04-18 15:23:08
合計ジャッジ時間 14,062 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 711 ms
394,132 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 12 ms
9,536 KB
testcase_07 AC 124 ms
78,124 KB
testcase_08 AC 666 ms
379,860 KB
testcase_09 AC 577 ms
332,856 KB
testcase_10 AC 628 ms
360,160 KB
testcase_11 AC 674 ms
375,156 KB
testcase_12 AC 678 ms
385,272 KB
testcase_13 AC 699 ms
390,412 KB
testcase_14 AC 702 ms
392,376 KB
testcase_15 AC 696 ms
393,352 KB
testcase_16 AC 706 ms
393,888 KB
testcase_17 AC 696 ms
393,968 KB
testcase_18 AC 698 ms
394,160 KB
testcase_19 AC 698 ms
394,080 KB
testcase_20 AC 699 ms
394,228 KB
testcase_21 AC 700 ms
394,264 KB
testcase_22 AC 130 ms
81,596 KB
testcase_23 AC 263 ms
159,772 KB
testcase_24 AC 394 ms
237,972 KB
testcase_25 AC 538 ms
315,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define Pr pair<ll,ll>
#define Tp tuple<ll,ll,ll>
using Graph = vector<vector<Pr>>;

ll mod = 998244353;

int main() {
    ll N; cin >> N;
    int nsf[N+1];
    rep(i,N+1){
        nsf[i] = i;
    }
    for(ll i=1;i<=N;i++){
        if(nsf[i]==i){
            rep(j,N){
                if(i*j*j>N) break;
                nsf[i*j*j] = i;
            }
        }
    }
    int counter[N+1];
    ll k = N;
    rep(i,N+1){
        while((ll)i*k*k>N) k--;
        counter[i] = k;
    }
    ll ans = 0;
    rep(i,N){
        ans += counter[nsf[i+1]];
    }
    cout << ans << endl;
}
0