結果

問題 No.1514 Squared Matching
ユーザー jelljell
提出日時 2021-05-21 22:43:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 205 ms / 4,000 ms
コード長 352 bytes
コンパイル時間 748 ms
コンパイル使用メモリ 72,000 KB
実行使用メモリ 9,828 KB
最終ジャッジ日時 2024-04-18 16:09:47
合計ジャッジ時間 4,934 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
9,684 KB
testcase_01 AC 201 ms
9,728 KB
testcase_02 AC 4 ms
9,600 KB
testcase_03 AC 5 ms
9,600 KB
testcase_04 AC 5 ms
9,576 KB
testcase_05 AC 5 ms
9,712 KB
testcase_06 AC 7 ms
9,584 KB
testcase_07 AC 41 ms
9,600 KB
testcase_08 AC 193 ms
9,640 KB
testcase_09 AC 171 ms
9,560 KB
testcase_10 AC 184 ms
9,728 KB
testcase_11 AC 193 ms
9,640 KB
testcase_12 AC 197 ms
9,728 KB
testcase_13 AC 199 ms
9,600 KB
testcase_14 AC 200 ms
9,600 KB
testcase_15 AC 200 ms
9,680 KB
testcase_16 AC 201 ms
9,728 KB
testcase_17 AC 201 ms
9,600 KB
testcase_18 AC 201 ms
9,728 KB
testcase_19 AC 205 ms
9,552 KB
testcase_20 AC 201 ms
9,728 KB
testcase_21 AC 200 ms
9,724 KB
testcase_22 AC 44 ms
9,668 KB
testcase_23 AC 83 ms
9,828 KB
testcase_24 AC 124 ms
9,648 KB
testcase_25 AC 162 ms
9,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bitset>
#include <iostream>

int main() {
  int n;
  std::cin >> n;
  std::bitset<50000001> used;
  long ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (used[i]) continue;
    long size = 0;
    for (long j = 1; j * j * i <= n; ++j) {
      used[j * j * i] = 1;
      ++size;
    }
    ans += size * size;
  }
  std::cout << ans << "\n";
}
0