結果

問題 No.853 河原の石
コンテスト
ユーザー risujiroh
提出日時 2019-07-26 21:58:15
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 436 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 988 ms
コンパイル使用メモリ 181,512 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-23 12:10:52
合計ジャッジ時間 2,955 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 4 WA * 53
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  lint h, w; cin >> h >> w;
  w = abs(w);
  if (!h or !w) return cout << 0 << '\n', 0;
  lint q = w / h, r = w - q * h;
  lint res = q * (h * (h + 1) / 2) + (r ? h + r * (r - 1) / 2 : 0);
  cout << res << '\n';
}
0