結果

問題 No.1514 Squared Matching
ユーザー 👑 KazunKazun
提出日時 2021-05-22 04:14:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 844 ms / 4,000 ms
コード長 532 bytes
コンパイル時間 809 ms
コンパイル使用メモリ 69,748 KB
実行使用メモリ 393,856 KB
最終ジャッジ日時 2024-04-18 17:19:55
合計ジャッジ時間 15,529 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 844 ms
393,820 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 13 ms
9,196 KB
testcase_07 AC 141 ms
78,020 KB
testcase_08 AC 782 ms
379,756 KB
testcase_09 AC 664 ms
332,288 KB
testcase_10 AC 739 ms
359,896 KB
testcase_11 AC 778 ms
374,912 KB
testcase_12 AC 808 ms
385,152 KB
testcase_13 AC 816 ms
390,060 KB
testcase_14 AC 826 ms
392,108 KB
testcase_15 AC 832 ms
393,216 KB
testcase_16 AC 827 ms
393,512 KB
testcase_17 AC 830 ms
393,728 KB
testcase_18 AC 839 ms
393,856 KB
testcase_19 AC 831 ms
393,820 KB
testcase_20 AC 829 ms
393,816 KB
testcase_21 AC 833 ms
393,856 KB
testcase_22 AC 147 ms
81,280 KB
testcase_23 AC 309 ms
159,616 KB
testcase_24 AC 460 ms
237,572 KB
testcase_25 AC 627 ms
315,776 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;
        }
    }
    
    for (int i=1; i<=N; i++) S[i]+=S[i-1];
    
    long long X=0;
    for (int i=1; i<=N; i++) X+=S[N/U[i]];
    
    cout << X << endl;
    
}
0