結果

問題 No.278 連続する整数の和(2)
ユーザー nanasili
提出日時 2015-09-18 16:49:59
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 947 ms
コンパイル使用メモリ 81,448 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 09:07:10
合計ジャッジ時間 1,876 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |   scanf("%lld", &n);
      |   ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;
typedef double d;

int main() {
  ll n;
  scanf("%lld", &n);
  ll x = n%2 ? n : n/2;
  ll cnt = 0;
  for (ll i = 1; i*i <= x; i++) {
    if (x%i) continue;
    cnt += i;
    if (i*i != x) {
      cnt += x/i;
    }
  }


  printf("%lld\n", cnt);
}
0