結果
| 問題 | No.3824 GCD of All |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2026-11-24 15:00:55 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 3 ms / 2,000 ms |
| + 903µs | |
| コード長 | 713 bytes |
| 記録 | |
| コンパイル時間 | 368 ms |
| コンパイル使用メモリ | 77,920 KB |
| 実行使用メモリ | 9,868 KB |
| 最終ジャッジ日時 | 2026-11-24 15:01:01 |
| 合計ジャッジ時間 | 2,385 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 3824.cc: No.3824 GCD of All - yukicoder
*/
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
/* constant */
/* typedef */
using ll = long long;
using vl = vector<ll>;
/* global variables */
/* subroutines */
/* main */
int main() {
ll m;
scanf("%lld", &m);
if (m == 1) { puts("1"); return 0; }
vl ds;
for (ll p = 1; p * p <= m; p++)
if (m % p == 0) {
ds.push_back(p);
ll q = m / p;
if (q != p) ds.push_back(q);
}
sort(ds.begin(), ds.end());
ll sum = m;
int l = (int)ds.size();
for (int i = 0; i + 1 < l; i++)
sum += ds[i] * (m / ds[i] - m / ds[i + 1]);
printf("%lld\n", sum);
return 0;
}
tnakao0123