結果
問題 | No.1624 三角形の反射 |
ユーザー |
|
提出日時 | 2021-07-23 22:16:18 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 311 ms / 2,000 ms |
コード長 | 1,062 bytes |
コンパイル時間 | 11,587 ms |
コンパイル使用メモリ | 437,860 KB |
実行使用メモリ | 52,136 KB |
最終ジャッジ日時 | 2024-07-02 09:53:39 |
合計ジャッジ時間 | 20,474 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
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