結果

問題 No.888 約数の総和
ユーザー kpinkcat
提出日時 2023-08-22 17:06:29
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 336 bytes
コンパイル時間 902 ms
コンパイル使用メモリ 99,928 KB
最終ジャッジ日時 2025-02-16 12:19:16
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /usr/include/c++/13/iostream:41,
                 from main.cpp:1:
In member function ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]’,
    inlined from ‘int main()’ at main.cpp:19:13:
/usr/include/c++/13/ostream:204:25: warning: ‘sum1’ may be used uninitialized [-Wmaybe-uninitialized]
  204 |       { return _M_insert(__n); }
      |                ~~~~~~~~~^~~~~
main.cpp: In function ‘int main()’:
main.cpp:14:18: note: ‘sum1’ was declared here
   14 |     long long n, sum1;
      |                  ^~~~

ソースコード

diff #

#include<iostream>
#include<map>
#include<vector>
#include <algorithm>
#include<math.h>
#include <iomanip>
#include<set>
#include <numeric>
using namespace std;


int main()
{
    long long n, sum1;
    cin >> n;
    for (long long i = 1; i <= pow(n, 0.5); i++){
        if (!(n%i)) sum1 += (i + n/i);
    }
    cout << sum1 << endl;
}
0