結果

問題 No.111 あばばばば
ユーザー tentententen
提出日時 2021-02-09 11:20:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 446 bytes
コンパイル時間 2,203 ms
コンパイル使用メモリ 72,860 KB
実行使用メモリ 56,676 KB
最終ジャッジ日時 2023-09-20 21:37:21
合計ジャッジ時間 4,322 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,172 KB
testcase_01 AC 121 ms
55,816 KB
testcase_02 AC 122 ms
55,828 KB
testcase_03 AC 121 ms
56,108 KB
testcase_04 AC 122 ms
56,012 KB
testcase_05 AC 122 ms
56,676 KB
testcase_06 AC 123 ms
55,484 KB
testcase_07 AC 127 ms
55,792 KB
testcase_08 AC 123 ms
55,612 KB
testcase_09 AC 124 ms
55,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans;
        if (n % 2 == 0) {
            long base = (n - 2) / 2;
            ans = (1 + base) * base;
        } else {
            long base = (n - 2) / 2;
            ans = (1 + base) * base;
            ans += n / 2;
        }
        System.out.println(ans);
    }
}
0