結果

問題 No.1514 Squared Matching
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-05-21 22:36:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 831 bytes
コンパイル時間 1,527 ms
コンパイル使用メモリ 166,564 KB
実行使用メモリ 589,288 KB
最終ジャッジ日時 2024-04-18 16:07:11
合計ジャッジ時間 21,122 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 MLE -
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 17 ms
12,288 KB
testcase_07 AC 191 ms
115,064 KB
testcase_08 MLE -
testcase_09 AC 907 ms
496,872 KB
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
testcase_21 MLE -
testcase_22 AC 206 ms
120,348 KB
testcase_23 AC 419 ms
237,688 KB
testcase_24 AC 627 ms
354,852 KB
testcase_25 AC 853 ms
472,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;

#define rep(i,n,m) for(ll (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(ll (i)=(n);(i)>(m);(i)--)
using ll = long long;
const ll mod = 998244353;


int main(){

    ll N;
    cin >> N;

    vector<ll> maxd(N+1,1);

    rep(i,1,N+1){
        for (ll j = i*i ; j < N+1 ; j += i*i){
            maxd[j] = max(maxd[j],i*i);
        }
    }

    vector<int> xlis(N+1,0);
    rep(i,1,N+1){
        ll x = i / maxd[i];
        xlis[x]++;
    }

    //aの値が、 平方数 * そうでない数x は求まった
    //そうでない数xで分類すればよい
    //あとは適当にペア計算

    ll ans = 0;
    rep(i,0,N+1){
        ans += xlis[i]*((ll)xlis[i]);
    }

    cout << ans << endl;

}
0