結果

問題 No.480 合計
ユーザー GBGB
提出日時 2018-04-08 14:08:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 354 bytes
コンパイル時間 1,788 ms
コンパイル使用メモリ 71,856 KB
実行使用メモリ 49,436 KB
最終ジャッジ日時 2023-09-09 03:07:40
合計ジャッジ時間 3,657 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
49,208 KB
testcase_01 AC 41 ms
47,584 KB
testcase_02 AC 43 ms
49,300 KB
testcase_03 AC 42 ms
49,436 KB
testcase_04 AC 43 ms
49,168 KB
testcase_05 AC 42 ms
49,040 KB
testcase_06 AC 42 ms
49,304 KB
testcase_07 AC 41 ms
49,248 KB
testcase_08 AC 41 ms
49,404 KB
testcase_09 AC 41 ms
49,192 KB
testcase_10 AC 41 ms
49,284 KB
testcase_11 AC 42 ms
49,260 KB
testcase_12 AC 41 ms
49,196 KB
testcase_13 AC 42 ms
49,136 KB
testcase_14 AC 41 ms
49,332 KB
testcase_15 AC 40 ms
47,220 KB
testcase_16 AC 42 ms
49,240 KB
testcase_17 AC 41 ms
49,044 KB
testcase_18 AC 40 ms
49,216 KB
testcase_19 AC 41 ms
49,144 KB
testcase_20 AC 41 ms
49,204 KB
testcase_21 AC 42 ms
49,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;

class Main{
  public static void main(String[] args)throws IOException {

    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int n=Integer.parseInt(br.readLine());
    int sum=0;

    if(n%2==0){
      sum=(n/2)*(n+1);
    }else{
      sum=((n+1)/2)+(n+1)*(n-1)/2;
    }

    System.out.println(sum);
  }
}
0