結果

問題 No.236 鴛鴦茶
ユーザー ともきともき
提出日時 2015-07-05 23:09:38
言語 Scala(Beta)
(3.3.1)
結果
AC  
実行時間 988 ms / 2,000 ms
コード長 1,259 bytes
コンパイル時間 11,103 ms
コンパイル使用メモリ 260,472 KB
実行使用メモリ 62,332 KB
最終ジャッジ日時 2023-09-11 11:29:20
合計ジャッジ時間 35,544 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 937 ms
62,164 KB
testcase_01 AC 941 ms
62,068 KB
testcase_02 AC 935 ms
61,900 KB
testcase_03 AC 936 ms
61,916 KB
testcase_04 AC 929 ms
62,112 KB
testcase_05 AC 933 ms
61,812 KB
testcase_06 AC 937 ms
62,024 KB
testcase_07 AC 931 ms
61,988 KB
testcase_08 AC 988 ms
61,948 KB
testcase_09 AC 929 ms
62,020 KB
testcase_10 AC 931 ms
61,972 KB
testcase_11 AC 941 ms
61,976 KB
testcase_12 AC 933 ms
62,104 KB
testcase_13 AC 923 ms
61,908 KB
testcase_14 AC 931 ms
62,072 KB
testcase_15 AC 932 ms
62,056 KB
testcase_16 AC 933 ms
62,156 KB
testcase_17 AC 941 ms
62,332 KB
testcase_18 AC 933 ms
62,096 KB
testcase_19 AC 933 ms
62,232 KB
testcase_20 AC 935 ms
61,844 KB
testcase_21 AC 937 ms
61,812 KB
testcase_22 AC 938 ms
61,916 KB
testcase_23 AC 938 ms
62,044 KB
testcase_24 AC 944 ms
62,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import scala.io.StdIn.readLine
import scala.collection.mutable.PriorityQueue
import scala.annotation.tailrec

// PriorityQueue[Long]()(scala.math.Ordering.Long.reverse)
object Lib {
  object Number {
    // @return Array length is equal to 'n'.
    //  Kth element of Array is true if K is prime else false.
    final def sieve(n : Int) : Array[Boolean] = {
      val isprime = Array.fill(n+1)(true)
      isprime(0) = false
      isprime(1) = false
      for(i <- 2 to Math.ceil(Math.sqrt(n.toDouble)).toInt;
          if isprime(i);
          j <- i*i to n by i){
        isprime(j) = false
      }
      isprime
    }
    // @return Array of primes that is less than or equal to n
    final def primes(n : Int) : Array[Int] =
      sieve(n).zipWithIndex.withFilter(_._1).map(_._2)
  }
  object EnRich {
    implicit class AString(val self : String) extends AnyVal {
      def splitToIntArray = self.split(" ").map(_.toInt)
    }
  }
}

import Lib.EnRich._
object Main {
  def main(args : Array[String]) : Unit = {
    val (a,b,x,y) = {
      val abxy = readLine().splitToIntArray.map(_.toDouble)
      (abxy(0),abxy(1),abxy(2),abxy(3))
    }

    val ret = if(x/a <= y/b) x+x/a*b // many cofee
              else y+y/b*a //many tea

    println(ret)
  }
}
0