結果
問題 |
No.1737 One to N
|
ユーザー |
|
提出日時 | 2021-11-13 17:50:45 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 508 bytes |
コンパイル時間 | 3,780 ms |
コンパイル使用メモリ | 247,052 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 16:05:58 |
合計ジャッジ時間 | 3,328 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h> using std::cin; using std::cout; using std::vector; using P = std::pair<int, int>; vector<P> factorize(int n) { vector<P> res; for (int i = 2; i * i <= n; ++i) { if (n % i) continue; res.emplace_back(i, 0); while (n%i == 0) { n /= i; res.back().second++; } } if (n != 1) res.emplace_back(n, 1); return res; } int main() { int n; cin >> n; auto f = factorize(n); int ans = 0; for (auto [x, y] : f) { ans += x*y; } cout << ans << '\n'; return 0; }