結果

問題 No.988 N×Mマス計算(総和)
ユーザー mikhailmikhail
提出日時 2020-03-22 20:32:14
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 2,671 bytes
コンパイル時間 17,598 ms
コンパイル使用メモリ 433,764 KB
実行使用メモリ 67,412 KB
最終ジャッジ日時 2023-09-20 12:19:00
合計ジャッジ時間 27,188 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 289 ms
53,076 KB
testcase_01 AC 300 ms
52,972 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 296 ms
53,000 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 301 ms
53,084 KB
testcase_08 AC 296 ms
54,788 KB
testcase_09 AC 294 ms
53,040 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 543 ms
60,444 KB
testcase_14 WA -
testcase_15 AC 457 ms
58,456 KB
testcase_16 AC 606 ms
64,080 KB
testcase_17 AC 672 ms
63,844 KB
testcase_18 AC 583 ms
62,500 KB
testcase_19 AC 665 ms
63,720 KB
testcase_20 AC 695 ms
65,952 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:9:10: warning: parameter 'args' is never used
fun main(args: Array<String>){
         ^
Main.kt:63:118: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Int
fun max(a: Int = -INF, b: Int = -INF, c: Int = -INF, d: Int = -INF, e: Int = -INF): Int = listOf(a, b, c, d, e).max()!!
                                                                                                                     ^
Main.kt:64:129: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Long
fun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long = listOf(a, b, c, d, e).max()!!.toLong()
                                                                                                                                ^
Main.kt:65:124: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Long
fun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long = listOf(a, b, c, d, e).min()!!.toLong()
                                                                                                                           ^

ソースコード

diff #

import java.util.*
import java.io.PrintWriter

val pw = PrintWriter(System.out)
val MOD = 1000000007L
val INF = 2147483647
val LINF = 9223372036854775807L

fun main(args: Array<String>){
    solve()
    pw.flush()    
}

fun solve(){
    val (n, m, k) = nextIntList()
    val list = nextList()
    val op = list.first()
    val b = list.drop(1).map{ it.toLong() }
    val bsum = b.sum()
    val a = nextLongAryln(n)

    var ans = 0L
    if(op.equals("+")){
        for (i in a.indices) {
            ans = (ans + a[i] * m.toLong() + bsum) % k.toLong()
        }
    } else {
        for (i in a.indices) {
            ans = (ans + a[i] * bsum) % k.toLong()
        }
    }

    println(ans)

}

// Print
fun println(v: String){
    pw.println(v)
}
fun print(v: String){
    pw.print(v)
}

// Read
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map{ it.toInt() }
fun nextLongList() = next().split(" ").map{ it.toLong() }
fun nextDoubleList() = next().split(" ").map{ it.toDouble() }
fun nextAryln(n: Int) = Array(n){ next() }
fun nextIntAryln(n: Int) = IntArray(n){ nextInt() }
fun nextLongAryln(n: Int) = LongArray(n){ nextLong() }
fun nextDoubleAryln(n: Int) = DoubleArray(n) { nextDouble() }

// Math
fun abs(n: Int) : Int = Math.abs(n)
fun abs(n: Long) : Long = Math.abs(n)
fun abs(n: Double) : Double = Math.abs(n)
fun max(a: Int = -INF, b: Int = -INF, c: Int = -INF, d: Int = -INF, e: Int = -INF): Int = listOf(a, b, c, d, e).max()!!
fun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long = listOf(a, b, c, d, e).max()!!.toLong()
fun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long = listOf(a, b, c, d, e).min()!!.toLong()
fun prime(from: Long, to: Long = from) : List<Long>{
    return (from..to).filter{ i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all{ j -> i % j != 0L}
    }
}
fun gcd(a: Long, b: Long) : Long = if(a % b == 0L) b else gcd(b, (a % b))
fun lcm(a: Long, b: Long) : Long = a / gcd(a, b) * b
fun modpow(a: Long, n: Long, p:Long = MOD) : Long {
    var res = 1L
    var ar = a
    var nr = n
    while(nr > 0){
        if((nr and 1) == 1L) res = res * ar % p
        ar = ar * ar % p
        nr = nr shr 1
    }
    return res
}
fun modinv(a: Long, p: Long = MOD) : Long = modpow(a, p - 2, p)
fun ncr(n: Long, r: Long) : Long {
    var a = 1L
    var b = 1L
    for (i in 1..r) {
        a = a * (n + 1 - i) % MOD
        b = b * i % MOD
    }
    return modinv(b, MOD) * a % MOD
}
0