結果
問題 | No.1737 One to N |
ユーザー |
|
提出日時 | 2021-11-26 12:27:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 984 bytes |
コンパイル時間 | 1,619 ms |
コンパイル使用メモリ | 169,552 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-29 03:23:43 |
合計ジャッジ時間 | 2,881 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include<bits/stdc++.h>#include<iostream>using namespace std;using LL = long long;using P = pair<int,int>;using Graph = vector<vector<int>>;const int INF = 1 << 29;const long long LINF = 1LL << 60;#define all(x) (x).begin(), (x).end()#define rep(i,n) for(int i = 0; i < (n); ++i)template<class T>void chmin(T&a, T b){if(a > b) a = b;}template<class T>void chmax(T&a, T b){if(a < b) a = b;}vector<pair<long long, long long>> prime_factorize(long long N){vector<pair<long long, long long>> res;for(long long a = 2; a * a <= N; ++a){if(N%a != 0) continue;long long ex = 0;while(N % a == 0){++ex;N /= a;}res.push_back({a, ex});}if(N != 1) res.push_back({N, 1});return res;}int main(){//inputint N; cin >> N;if(N == 1){cout << 0 << endl;return 0;}else{long long ans = 0;const auto &res = prime_factorize(N);for(auto p : res){ans += p.first * p.second;}cout << ans << endl;}}