結果

問題 No.821 Making Integers
ユーザー maimai
提出日時 2019-04-26 22:08:40
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 298 ms / 2,000 ms
コード長 311 bytes
コンパイル時間 8,620 ms
コンパイル使用メモリ 427,976 KB
実行使用メモリ 55,316 KB
最終ジャッジ日時 2024-04-30 20:26:17
合計ジャッジ時間 12,068 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 289 ms
55,148 KB
testcase_01 AC 285 ms
55,132 KB
testcase_02 AC 287 ms
55,188 KB
testcase_03 AC 293 ms
55,164 KB
testcase_04 AC 287 ms
55,268 KB
testcase_05 AC 286 ms
55,288 KB
testcase_06 AC 287 ms
55,284 KB
testcase_07 AC 298 ms
55,316 KB
testcase_08 AC 298 ms
55,312 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