結果

問題 No.71 そろばん
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-20 13:08:44
言語 Java19
(openjdk 21)
結果
AC  
実行時間 130 ms / 5,000 ms
コード長 407 bytes
コンパイル時間 1,969 ms
コンパイル使用メモリ 71,952 KB
実行使用メモリ 56,180 KB
最終ジャッジ日時 2023-09-18 00:50:30
合計ジャッジ時間 6,049 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,628 KB
testcase_01 AC 126 ms
55,524 KB
testcase_02 AC 123 ms
55,812 KB
testcase_03 AC 123 ms
56,156 KB
testcase_04 AC 123 ms
55,376 KB
testcase_05 AC 123 ms
55,880 KB
testcase_06 AC 127 ms
55,908 KB
testcase_07 AC 125 ms
55,972 KB
testcase_08 AC 125 ms
55,572 KB
testcase_09 AC 126 ms
55,468 KB
testcase_10 AC 129 ms
55,608 KB
testcase_11 AC 126 ms
55,928 KB
testcase_12 AC 125 ms
56,180 KB
testcase_13 AC 125 ms
55,952 KB
testcase_14 AC 127 ms
55,628 KB
testcase_15 AC 130 ms
55,628 KB
testcase_16 AC 124 ms
55,580 KB
testcase_17 AC 125 ms
55,436 KB
testcase_18 AC 124 ms
55,656 KB
testcase_19 AC 128 ms
55,532 KB
testcase_20 AC 126 ms
56,172 KB
testcase_21 AC 126 ms
55,832 KB
testcase_22 AC 128 ms
55,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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