結果
問題 | No.278 連続する整数の和(2) |
ユーザー |
![]() |
提出日時 | 2019-01-11 03:37:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 15 ms / 2,000 ms |
コード長 | 441 bytes |
コンパイル時間 | 213 ms |
コンパイル使用メモリ | 40,960 KB |
最終ジャッジ日時 | 2025-01-06 20:14:02 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%jd", &N); | ~~~~~^~~~~~~~~~~
ソースコード
#include <cstdio> #include <cstdint> #include <algorithm> __int128 gcd(__int128 m, __int128 n) { while (n) std::swap(m%=n, n); return m; } int main() { intmax_t N; scanf("%jd", &N); intmax_t M = gcd(N, __int128(N)*(N+1) / 2); intmax_t res = 0; for (intmax_t i = 1; i*i <= M; ++i) { if (M % i == 0) { res += i; if (i != M / i) res += M / i; } } printf("%jd\n", res); }