結果

問題 No.311 z in FizzBuzzString
ユーザー nnsniconnsnico
提出日時 2022-09-18 03:39:48
言語 Kotlin
(1.9.23)
結果
RE  
実行時間 -
コード長 678 bytes
コンパイル時間 13,581 ms
コンパイル使用メモリ 432,940 KB
実行使用メモリ 54,352 KB
最終ジャッジ日時 2023-10-25 03:03:49
合計ジャッジ時間 15,315 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 298 ms
54,320 KB
testcase_01 AC 297 ms
54,328 KB
testcase_02 AC 297 ms
54,328 KB
testcase_03 AC 296 ms
54,332 KB
testcase_04 AC 297 ms
54,328 KB
testcase_05 AC 309 ms
54,352 KB
testcase_06 AC 301 ms
54,352 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:3:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^

ソースコード

diff #

import java.io.PrintWriter

fun main(args: Array<String>) {
  val pw = PrintWriter(System.out)

  val n = readLine()?.toInt() ?: 0

  val result =
      (1..n)
          .toList()
          .fold(
              0,
              { acc, a ->
                when {
                  a % 3 == 0 && a % 5 == 0 -> {
                    acc + 4
                  }
                  a % 3 == 0 -> {
                    acc + 2
                  }
                  a % 5 == 0 -> {
                    acc + 2
                  }
                  else -> {
                    acc
                  }
                }
              }
          )

  pw.println(result)

  pw.flush()
}
0