結果

問題 No.821 Making Integers
ユーザー maimai
提出日時 2019-04-26 22:08:40
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 322 ms / 2,000 ms
コード長 311 bytes
コンパイル時間 11,075 ms
コンパイル使用メモリ 416,840 KB
実行使用メモリ 53,940 KB
最終ジャッジ日時 2023-08-13 01:53:01
合計ジャッジ時間 15,164 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 322 ms
53,448 KB
testcase_01 AC 312 ms
53,940 KB
testcase_02 AC 318 ms
53,484 KB
testcase_03 AC 314 ms
53,376 KB
testcase_04 AC 310 ms
53,364 KB
testcase_05 AC 319 ms
53,368 KB
testcase_06 AC 316 ms
53,548 KB
testcase_07 AC 306 ms
53,636 KB
testcase_08 AC 312 ms
53,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner
val scanner = Scanner(System.`in`)

fun sum(be:Long, la:Long): Long = (la-be+1)*(be+la)/2

fun main(){
    var n = scanner.nextLong()
    var k = scanner.nextLong()
    
    val total = sum(1,n)
    val mi = sum(1, n-k)-sum(n-k+1, n)
    
    val ans = (total-mi)/2+1
    println(ans)
}
0