結果

問題 No.1514 Squared Matching
ユーザー chocoruskchocorusk
提出日時 2021-05-21 21:24:12
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 929 ms / 4,000 ms
コード長 971 bytes
コンパイル時間 3,558 ms
コンパイル使用メモリ 185,600 KB
実行使用メモリ 394,240 KB
最終ジャッジ日時 2024-04-18 14:24:41
合計ジャッジ時間 19,659 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 929 ms
394,240 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 12 ms
9,600 KB
testcase_07 AC 162 ms
78,208 KB
testcase_08 AC 876 ms
380,032 KB
testcase_09 AC 769 ms
332,544 KB
testcase_10 AC 834 ms
360,064 KB
testcase_11 AC 864 ms
375,040 KB
testcase_12 AC 882 ms
385,408 KB
testcase_13 AC 891 ms
390,400 KB
testcase_14 AC 898 ms
392,448 KB
testcase_15 AC 900 ms
393,472 KB
testcase_16 AC 894 ms
393,984 KB
testcase_17 AC 898 ms
393,984 KB
testcase_18 AC 909 ms
394,112 KB
testcase_19 AC 906 ms
394,112 KB
testcase_20 AC 902 ms
394,240 KB
testcase_21 AC 902 ms
394,240 KB
testcase_22 AC 164 ms
81,664 KB
testcase_23 AC 348 ms
159,872 KB
testcase_24 AC 539 ms
237,824 KB
testcase_25 AC 727 ms
316,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
int x[50000010];
int c[50000010];
int main()
{
    int n; cin>>n;
    for(int i=1; i<=n; i++) x[i]=i;
    for(int i=2; i*i<=n; i++){
        for(int j=i*i; j<=n; j+=i*i){
            while(x[j]%(i*i)==0) x[j]/=(i*i);
        }
    }
    for(int i=1; i<=n; i++) c[x[i]]++;
    ll ans=0;
    for(int i=1; i<=n; i++) ans+=(ll)c[i]*c[i];
    cout<<ans<<endl;

    return 0;
}
0