結果

問題 No.278 連続する整数の和(2)
ユーザー 37kt_37kt_
提出日時 2016-02-24 15:38:13
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,716 bytes
コンパイル時間 1,178 ms
コンパイル使用メモリ 160,152 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 19:36:48
合計ジャッジ時間 2,763 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define GET_MACRO(a, b, c, d, e, NAME, ...) NAME
#define REP1(n) REP2(i_, n)
#define REP2(i, n) REP3(i, 0, n)
#define REP3(i, a, b) REP4(i, a, b, 1)
#define REP4(i, a, b, s) for (long long i = (a); i < (long long)(b); i += (long long)(s))
#define RREP1(n) RREP2(i_, n)
#define RREP2(i, n) RREP3(i, 0, n)
#define RREP3(i, a, b) RREP4(i, a, b, 1)
#define RREP4(i, a, b, s) for (long long i = (b) - 1; i >= (long long)(a);  i -= (long long)(s))
#define rep(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2, REP1)(__VA_ARGS__)
#define rrep(...) GET_MACRO(__VA_ARGS__, RREP4, RREP3, RREP2, RREP1)(__VA_ARGS__)
#define fs first
#define sc second
#define all(c) std::begin(c), std::end(c)
#define dump(...) std::cerr << "("#__VA_ARGS__") = " << std::make_tuple(__VA_ARGS__) << "\n"
#define y0 y0_
#define y1 y1_
#define yn yn_

using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using V2 = vector<V<T>>;
template<typename T> using V3 = vector<V2<T>>;
template<typename T> using V4 = vector<V3<T>>;
using vi = V<int>;
using vu = V<uint>;
using vl = V<ll>;
using vul = V<ull>;
using vd = V<double>;
using vld = V<ld>;
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T>;

template<typename T> inline constexpr T sq(T x){ return x * x; }
template<typename T, typename U> inline T& chmin(T &x, U y){ if (x > y) x = y; return x; }
template<typename T, typename U> inline T& chmax(T &x, U y){ if (x < y) x = y; return x; }

const string delimiter = " ";

void setDelimiter(const string &d){
  const_cast<string &>(delimiter) = d;
}

template<size_t N, typename ...T>
typename enable_if<(N >= sizeof...(T))>::type
print_tuple(ostream &, const tuple<T...> &, const string &){
}

template<size_t N, typename ...T>
typename enable_if<(N < sizeof...(T))>::type
print_tuple(ostream &os, const tuple<T...> &x, const string &delim = delimiter){
  os << (N > 0 ? delim : "") << get<N>(x);
  print_tuple<N + 1, T...>(os, x, delim);
}

template<typename ...T>
ostream &operator<<(ostream &os, const tuple<T...> &x){
  if (&os == &cerr) print_tuple<0, T...>(os, x, " ");
  else print_tuple<0, T...>(os, x);
  return os;
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &x){
  return os << x.first << delimiter << x.second;
}
/* }}} */

signed main()
{
  ll n; cin >> n;
  ll r = 0;
  for (ll i = 1; i * i <= n; i++){
    if (n % i == 0){
      r += i;
      if (i * i < n) r += n / i;
    }
  }
  cout << r << endl;
}
0