結果

問題 No.1514 Squared Matching
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-05-21 22:39:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 850 bytes
コンパイル時間 2,209 ms
コンパイル使用メモリ 201,876 KB
実行使用メモリ 533,152 KB
最終ジャッジ日時 2024-04-18 16:08:55
合計ジャッジ時間 7,623 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 MLE -
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>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <map>

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;

    map<ll,ll> maxd;

    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 / max((ll)1,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