結果

問題 No.1514 Squared Matching
ユーザー kai4096_donkai4096_don
提出日時 2021-09-10 22:16:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 702 ms / 4,000 ms
コード長 589 bytes
コンパイル時間 3,931 ms
コンパイル使用メモリ 227,928 KB
実行使用メモリ 394,008 KB
最終ジャッジ日時 2023-09-02 18:16:52
合計ジャッジ時間 15,276 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 702 ms
393,640 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 8 ms
8,988 KB
testcase_07 AC 89 ms
77,860 KB
testcase_08 AC 576 ms
379,568 KB
testcase_09 AC 485 ms
332,568 KB
testcase_10 AC 528 ms
359,816 KB
testcase_11 AC 557 ms
374,456 KB
testcase_12 AC 587 ms
384,732 KB
testcase_13 AC 592 ms
389,956 KB
testcase_14 AC 595 ms
391,988 KB
testcase_15 AC 594 ms
392,980 KB
testcase_16 AC 589 ms
393,508 KB
testcase_17 AC 586 ms
393,864 KB
testcase_18 AC 580 ms
393,504 KB
testcase_19 AC 578 ms
394,008 KB
testcase_20 AC 577 ms
393,496 KB
testcase_21 AC 591 ms
393,828 KB
testcase_22 AC 94 ms
81,164 KB
testcase_23 AC 190 ms
159,420 KB
testcase_24 AC 322 ms
237,536 KB
testcase_25 AC 460 ms
315,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
//const long nPrime = 1000000007;
//const long nPrime = 998244353;
typedef long long ll;
int main() {
    long n;
    cin >> n;
    vector<long> viCheck(n+1,0);
    long nAns = 0;
    for(long i = 1; i <= n; i++){
        if(viCheck[i] == 1){
            continue;
        }
        long nCount = 1;
        for(; i*nCount*nCount <= n; nCount++){
            viCheck[i*nCount*nCount] = 1;
        }
        nCount--;
        nAns += nCount*nCount;
    }
    cout << nAns << endl;
    return 0;
}
0