結果

問題 No.683 Two Operations No.3
ユーザー 826814741_6
提出日時 2019-01-04 19:10:18
言語 Kotlin
(2.1.0)
結果
AC  
実行時間 329 ms / 2,000 ms
コード長 395 bytes
コンパイル時間 12,813 ms
コンパイル使用メモリ 437,284 KB
実行使用メモリ 51,956 KB
最終ジャッジ日時 2024-11-20 17:22:27
合計ジャッジ時間 18,669 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:10:10: warning: parameter 'args' is never used
fun main(args: Array<String>){
         ^

ソースコード

diff #

fun f (a: Long, b: Long): Boolean =
    when {
        a==0L||b==0L -> true
        a%2L==1L&&b%2L==1L -> false
        a%2L==0L&&b%2L==1L -> f(a/2L,b.dec())
        a%2L==1L&&b%2L==0L -> f(a.dec(),b/2L)
        else -> f(a/2L,b.dec()) || f(a.dec(),b/2L)
    }

fun main(args: Array<String>){
    val (a,b) = readLine()!!.split(' ').map(String::toLong)
    println(if (f(a,b)) "Yes" else "No")
}
0