結果

問題 No.821 Making Integers
ユーザー bluemeganebluemegane
提出日時 2019-04-27 18:51:44
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 442 bytes
コンパイル時間 2,880 ms
コンパイル使用メモリ 100,844 KB
実行使用メモリ 22,884 KB
最終ジャッジ日時 2023-08-19 10:15:26
合計ジャッジ時間 2,840 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
22,884 KB
testcase_01 AC 49 ms
20,804 KB
testcase_02 AC 50 ms
18,756 KB
testcase_03 AC 50 ms
20,900 KB
testcase_04 AC 49 ms
20,796 KB
testcase_05 AC 51 ms
22,852 KB
testcase_06 AC 50 ms
20,788 KB
testcase_07 AC 50 ms
20,924 KB
testcase_08 AC 52 ms
20,920 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = long.Parse(line[0]);
        var k = int.Parse(line[1]);
        var max = getSum(1, n);
        var min = getSum(1, n - k) - getSum(n -k + 1L, n);
        var ans = (max - min) / 2 + 1L;
        Console.WriteLine(ans);
    }
    static long getSum(long a, long b) => (b + a) * (b - a + 1) / 2L;
}

0