結果

問題 No.276 連続する整数の和(1)
ユーザー DaYuanChiDaYuanChi
提出日時 2021-02-06 15:57:14
言語 C++14
(gcc 12.2.0 + boost 1.81.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 215 bytes
コンパイル時間 1,315 ms
実行使用メモリ 3,544 KB
最終ジャッジ日時 2023-02-04 03:28:10
合計ジャッジ時間 2,277 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
3,364 KB
testcase_01 AC 2 ms
3,368 KB
testcase_02 AC 1 ms
3,472 KB
testcase_03 AC 1 ms
3,544 KB
testcase_04 AC 1 ms
3,432 KB
testcase_05 AC 1 ms
3,524 KB
testcase_06 AC 1 ms
3,488 KB
testcase_07 AC 1 ms
3,372 KB
testcase_08 AC 1 ms
3,420 KB
testcase_09 AC 1 ms
3,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  int n; cin >> n;
  //和=(2a+n-1)n/2
  int ans = 0;
  if(n%2==0) ans = n / 2;
  else ans = n;
  cout << ans << endl;
  return 0;
}
0