結果

問題 No.2937 Sigma Plus Problem
ユーザー tnakao0123
提出日時 2024-10-20 22:29:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1 ms / 300 ms
コード長 407 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 39,680 KB
最終ジャッジ日時 2025-02-24 22:03:31
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:25:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |   scanf("%llu", &n);
      |   ~~~~~^~~~~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2937.cc:  No.2937 Sigma Plus Problem - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

/* typedef */

using ull = unsigned long long;

/* global variables */

/* subroutines */

/* main */

int main() {
  ull n;
  scanf("%llu", &n);

  ull s = (n & 1) ? n * ((n + 1) / 2) : (n / 2) * (n + 1);
  printf("%llu\n", s);
  
  return 0;
}
0