Submission #2546171


Source Code Expand

import scala.io.StdIn

object Main extends App {
  val n: Array[Int] = StdIn.readLine().toCharArray.map(c => c - 48)
  var result = ""
  (0 to 1).foreach { ope1 =>
    (0 to 1).foreach { ope2 =>
      (0 to 1).foreach { ope3 =>
        val r1: Int = (if (ope1 == 1) n(0) + n(1) else n(0) - n(1))
        val r2: Int = (if (ope2 == 1) r1 + n(2) else r1 - n(2))
        val r3: Int = (if (ope3 == 1) r2 + n(3) else r2 - n(3))
        if (r3 == 7) {
          result = n(0).toString + (if (ope1 == 1) "+" else "-") + n(1).toString +
            (if (ope2 == 1) "+" else "-") + n(2).toString +
            (if (ope3 == 1) "+" else "-") + n(3).toString + "=7"
        }
      }
    }
  }
  
  println(result)
}

Submission Info

Submission Time
Task C - Train Ticket
User matsutomu
Language Scala (2.11.7)
Score 300
Code Size 728 Byte
Status AC
Exec Time 325 ms
Memory 27216 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 19
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
01.txt AC 317 ms 25272 KB
02.txt AC 325 ms 25424 KB
03.txt AC 320 ms 25284 KB
04.txt AC 319 ms 25244 KB
05.txt AC 318 ms 25136 KB
06.txt AC 318 ms 25276 KB
07.txt AC 318 ms 25280 KB
08.txt AC 315 ms 27216 KB
09.txt AC 319 ms 25292 KB
10.txt AC 325 ms 23496 KB
11.txt AC 317 ms 25392 KB
12.txt AC 321 ms 23624 KB
13.txt AC 319 ms 24888 KB
14.txt AC 322 ms 23612 KB
15.txt AC 318 ms 25292 KB
16.txt AC 321 ms 25408 KB
sample_01.txt AC 323 ms 25144 KB
sample_02.txt AC 320 ms 25380 KB
sample_03.txt AC 319 ms 25376 KB