結果
| 問題 | 
                            No.1514 Squared Matching
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-06-26 14:47:37 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                MLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 868 bytes | 
| コンパイル時間 | 896 ms | 
| コンパイル使用メモリ | 86,060 KB | 
| 実行使用メモリ | 553,688 KB | 
| 最終ジャッジ日時 | 2024-06-25 09:08:00 | 
| 合計ジャッジ時間 | 9,530 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | TLE * 1 MLE * 1 -- * 24 | 
ソースコード
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#define ll long long
using namespace std;
const int maxn=5e7+10;
int p[maxn];
map<int,int> cnt;
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;
}