結果

問題 No.2046 Ans Mod? Mod Ans!
ユーザー 👑 箱星箱星
提出日時 2021-07-18 20:30:17
言語 Kotlin
(1.9.23)
結果
TLE  
実行時間 -
コード長 794 bytes
コンパイル時間 14,666 ms
コンパイル使用メモリ 438,924 KB
実行使用メモリ 86,316 KB
最終ジャッジ日時 2024-05-09 17:15:11
合計ジャッジ時間 23,520 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 274 ms
53,256 KB
testcase_01 AC 258 ms
86,316 KB
testcase_02 AC 276 ms
49,836 KB
testcase_03 AC 304 ms
50,160 KB
testcase_04 AC 293 ms
50,292 KB
testcase_05 AC 300 ms
50,292 KB
testcase_06 AC 294 ms
50,204 KB
testcase_07 AC 293 ms
50,000 KB
testcase_08 AC 355 ms
50,532 KB
testcase_09 AC 365 ms
50,580 KB
testcase_10 AC 385 ms
50,580 KB
testcase_11 AC 524 ms
51,120 KB
testcase_12 AC 477 ms
51,112 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter
import java.util.*
import kotlin.math.*

fun PrintWriter.solve() {
    val n = nextInt()
    val a = Array(n) { nextInt() }
    var ans = 0L
    for (i in 0 until n) {
        for (j in i + 1 until n) {
            ans += (a[i] % a[j] - a[j] % a[i]).absoluteValue
        }
    }
    println(ans)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve()
    writer.flush()
}

// region Scanner
private var st = StringTokenizer("")
private val br = System.`in`.bufferedReader()

fun next(): String {
    while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())
    return st.nextToken()
}

fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextLine() = br.readLine()
fun nextDouble() = next().toDouble()
// endregion
0