結果

問題 No.1514 Squared Matching
ユーザー V_MelvilleV_Melville
提出日時 2021-06-26 01:21:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 784 bytes
コンパイル時間 555 ms
コンパイル使用メモリ 71,156 KB
実行使用メモリ 200,248 KB
最終ジャッジ日時 2023-09-07 13:40:56
合計ジャッジ時間 11,540 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,564 ms
200,248 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 <iostream>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;

const int maxn=5e7+10;
int p[maxn];
ll cnt[maxn];

void init(){
    p[1]=1;
    for(int i=2;i<maxn;i++){
        if(p[i]==0) {
            for (int j = i; j < maxn; j += i) {
                p[j] = i;
            }
        }
    }
}


int main(){
    ios::sync_with_stdio(false);
    init();

    int N;cin>>N;

    ll ans=0;
    for(int x=1;x<=N;x++){
        ans+=1;//ans+=(x,x)

        int K=x;
        int hash=1;
        while(K!=1){
            if(hash%p[K]==0){
                hash/=p[K];
            }else{
                hash*=p[K];
            }
            K/=p[K];
        }

        ans+=cnt[hash]*2;
        cnt[hash]+=1;
    }
    cout<<ans<<endl;
    return 0;
}
0