結果

問題 No.821 Making Integers
ユーザー lumc_lumc_
提出日時 2019-04-26 21:27:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 657 bytes
コンパイル時間 767 ms
コンパイル使用メモリ 99,912 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-16 13:02:05
合計ジャッジ時間 1,441 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

// return sum of [l, r]
long long rangesum(long long l, long long r) {
  return (r + l) * (r - l + 1) / 2;
}

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  ll n, k;
  cin >> n >> k;
  cout << rangesum(n - k + 1, n) + 1 << endl;

  return 0;
}
0