結果

問題 No.278 連続する整数の和(2)
ユーザー itezpaceitezpace
提出日時 2016-10-25 08:33:16
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 491 bytes
コンパイル時間 671 ms
コンパイル使用メモリ 67,260 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-03 05:58:03
合計ジャッジ時間 1,349 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 7 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 7 ms
5,376 KB
testcase_10 AC 8 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 1 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 5 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 7 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
  ll N=0;cin>>N;
  ll a=N;
  if(N%2==0) a=0;
  if(N>1) a+=1;
  if(a>1){
    vector<ll> v;
    for(ll i=3;i*i<=N;i+=2){
      if(N%i==0){
        v.push_back(i);
        v.push_back(N/i);
      }
    }
    sort(v.begin(),v.end());
    auto result=unique(v.begin(),v.end());
    v.erase(result,v.end());
    for(ll i=0;i<v.size();++i){
      a+=v[i];
    }
  }
  cout<<a<<endl;
}
0