結果

問題 No.1514 Squared Matching
コンテスト
ユーザー kai4096_don
提出日時 2021-09-10 22:16:59
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 226 ms / 4,000 ms
+ 783µs
コード長 589 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,042 ms
コンパイル使用メモリ 248,388 KB
実行使用メモリ 394,020 KB
最終ジャッジ日時 2026-10-16 15:01:50
合計ジャッジ時間 8,984 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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