結果

問題 No.1624 三角形の反射
ユーザー 👑 箱
提出日時 2021-07-23 22:16:18
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 319 ms / 2,000 ms
コード長 1,062 bytes
コンパイル時間 16,461 ms
コンパイル使用メモリ 418,524 KB
実行使用メモリ 53,000 KB
最終ジャッジ日時 2023-09-15 04:49:41
合計ジャッジ時間 22,943 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 301 ms
52,816 KB
testcase_01 AC 304 ms
52,752 KB
testcase_02 AC 305 ms
52,728 KB
testcase_03 AC 306 ms
52,720 KB
testcase_04 AC 311 ms
52,816 KB
testcase_05 AC 306 ms
52,676 KB
testcase_06 AC 308 ms
52,956 KB
testcase_07 AC 313 ms
52,992 KB
testcase_08 AC 310 ms
52,700 KB
testcase_09 AC 313 ms
52,556 KB
testcase_10 AC 319 ms
52,848 KB
testcase_11 AC 317 ms
52,640 KB
testcase_12 AC 316 ms
52,940 KB
testcase_13 AC 305 ms
52,520 KB
testcase_14 AC 307 ms
52,708 KB
testcase_15 AC 311 ms
52,740 KB
testcase_16 AC 311 ms
52,952 KB
testcase_17 AC 306 ms
52,784 KB
testcase_18 AC 309 ms
53,000 KB
testcase_19 AC 309 ms
52,864 KB
testcase_20 AC 312 ms
52,700 KB
testcase_21 AC 306 ms
52,620 KB
testcase_22 AC 306 ms
52,932 KB
testcase_23 AC 305 ms
52,676 KB
testcase_24 AC 307 ms
52,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fun gcd(a: Int, b: Int): Int {
    if (b == 0) return a
    val c = a % b
    return gcd(b, c)
}

fun PrintWriter.solve() {
    val s = nextLine()
    val n = s.replace(".", "").toInt()
    val d = gcd(n, 1000)
    val x = 1000 / d
    val y = n * x / 1000
    val final = if ((x + y) % 2 == 0) 'A' else if (x % 2 == 0) 'C' else 'B'
    var count = x + y - 2
    for (i in 1 until x + y step 2) {
        count++
    }
    for (i in 1 until (x - y).absoluteValue step 2) {
        count++
    }
    println("$final $count")
}

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