結果

問題 No.1318 ABCD quadruplets
ユーザー 👑 箱
提出日時 2020-12-21 12:23:59
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 919 ms / 2,000 ms
コード長 1,656 bytes
コンパイル時間 17,355 ms
コンパイル使用メモリ 444,960 KB
実行使用メモリ 62,212 KB
最終ジャッジ日時 2023-10-21 11:38:45
合計ジャッジ時間 33,670 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 315 ms
55,396 KB
testcase_01 AC 316 ms
55,400 KB
testcase_02 AC 316 ms
55,392 KB
testcase_03 AC 319 ms
55,396 KB
testcase_04 AC 314 ms
55,384 KB
testcase_05 AC 318 ms
55,400 KB
testcase_06 AC 313 ms
55,392 KB
testcase_07 AC 312 ms
55,400 KB
testcase_08 AC 318 ms
55,380 KB
testcase_09 AC 310 ms
55,388 KB
testcase_10 AC 311 ms
55,388 KB
testcase_11 AC 313 ms
55,396 KB
testcase_12 AC 316 ms
55,396 KB
testcase_13 AC 405 ms
58,772 KB
testcase_14 AC 617 ms
60,128 KB
testcase_15 AC 408 ms
58,788 KB
testcase_16 AC 690 ms
60,068 KB
testcase_17 AC 476 ms
60,024 KB
testcase_18 AC 601 ms
60,100 KB
testcase_19 AC 520 ms
60,092 KB
testcase_20 AC 416 ms
58,708 KB
testcase_21 AC 453 ms
58,792 KB
testcase_22 AC 464 ms
60,048 KB
testcase_23 AC 906 ms
62,164 KB
testcase_24 AC 856 ms
62,212 KB
testcase_25 AC 548 ms
62,144 KB
testcase_26 AC 509 ms
60,084 KB
testcase_27 AC 751 ms
62,176 KB
testcase_28 AC 563 ms
62,144 KB
testcase_29 AC 596 ms
62,156 KB
testcase_30 AC 919 ms
62,148 KB
testcase_31 AC 565 ms
62,144 KB
testcase_32 AC 919 ms
62,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fun PrintWriter.solve() {
    val n = nextInt()
    val m = nextInt()
    val ans = IntArray(n + 1) { 0 }
    for (a in 0..m) {
        for (b in 0..a) {
            for (c in 0..b) {
                for (d in 0..c) {
                    val k = a * a + a * b + a * c + a * d + b * b + b * c + b * d + c * c + c * d + d * d
                    if (k > n) break
                    if (a == b) {
                        if (b == c) {
                            if (c == d) ans[k] += 1
                            else ans[k] += 4
                        } else {
                            if (c == d) ans[k] += 6
                            else ans[k] += 12
                        }
                    } else {
                        if (b == c) {
                            if (c == d) ans[k] += 4
                            else ans[k] += 12
                        } else {
                            if (c == d) ans[k] += 12
                            else ans[k] += 24
                        }
                    }
                }
            }
        }
    }
    println(ans.joinToString("\n"))
}

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