結果

問題 No.888 約数の総和
ユーザー stella1225
提出日時 2023-12-09 20:25:21
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 460 bytes
コンパイル時間 1,604 ms
コンパイル使用メモリ 172,244 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-27 03:45:02
合計ジャッジ時間 2,961 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

//約数列挙
vector<ll> divisor_enumerate(ll N){
  vector<ll> res;
  for(ll i=1; i*i<=N; i++){
    if(N%i==0){
      res.push_back(i);
      if(i*i!=N) res.push_back(N/i);
    } 
  }
  sort(res.begin(), res.end());
  return res;
}

int main(){
  ll N; cin>>N;
  ll ans=0;
  vector<ll> res=divisor_enumerate(N);
  int n=res.size();
  for(ll i=0; i<n; i++) ans+=res[i];
  cout<<ans<<endl;
}
0