結果

問題 No.1514 Squared Matching
ユーザー 👑 KazunKazun
提出日時 2021-05-21 22:56:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 562 bytes
コンパイル時間 921 ms
コンパイル使用メモリ 69,716 KB
実行使用メモリ 589,472 KB
最終ジャッジ日時 2024-04-18 16:25:06
合計ジャッジ時間 16,829 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 MLE -
testcase_02 AC 2 ms
6,940 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 14 ms
12,280 KB
testcase_07 AC 156 ms
115,068 KB
testcase_08 MLE -
testcase_09 AC 759 ms
496,948 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 171 ms
120,416 KB
testcase_23 AC 345 ms
237,544 KB
testcase_24 AC 523 ms
354,812 KB
testcase_25 AC 692 ms
471,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>

using namespace std;

int main(){
    int N; cin >> N;
    vector<int> S(N+1,0); S[1]=1;
    vector<int> U(N+1);
    
    for (int i=0; i<=N; i++) U[i]=i;
    
    int j,k;
    for (int i=2; i*i<=N; i++){
        j=i*i;
        k=i*i;
        S[j]=1;
        while (j<=N){
            while (U[j]%k==0) U[j]/=k;
            j+=k;
        }
    }
    
    vector<int> V(N+1,0);
    for (int i=1; i<=N; i++) V[i]=V[i-1]+S[i];
    
    long long X=0;
    for (int i=1; i<=N; i++) X+=V[N/U[i]];
    
    cout << X << endl;
    
}
0