結果
問題 | No.638 Sum of "not power of 2" |
ユーザー | 💕💖💞 |
提出日時 | 2018-04-05 21:59:19 |
言語 | Kotlin (1.9.10) |
結果 |
WA
|
実行時間 | - |
コード長 | 662 bytes |
コンパイル時間 | 14,973 ms |
コンパイル使用メモリ | 410,924 KB |
実行使用メモリ | 52,864 KB |
最終ジャッジ日時 | 2023-08-12 23:16:40 |
合計ジャッジ時間 | 17,555 ms |
ジャッジサーバーID (参考情報) |
judge7 / judge2 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 273 ms
52,832 KB |
testcase_04 | AC | 271 ms
52,424 KB |
testcase_05 | AC | 273 ms
52,540 KB |
testcase_06 | AC | 273 ms
52,864 KB |
testcase_07 | AC | 273 ms
52,556 KB |
testcase_08 | AC | 274 ms
52,416 KB |
testcase_09 | AC | 273 ms
52,476 KB |
testcase_10 | AC | 283 ms
52,440 KB |
testcase_11 | AC | 283 ms
52,320 KB |
testcase_12 | AC | 285 ms
52,428 KB |
testcase_13 | AC | 284 ms
52,420 KB |
コンパイルメッセージ
Main.kt:3:10: warning: parameter 'args' is never used fun main(args:Array<String>) { ^
ソースコード
import java.math.BigDecimal fun main(args:Array<String>) { val n = readLine()!!.toBigDecimal() val m = ("1" + "0".repeat(18)).toBigDecimal() val bs = mutableSetOf<BigDecimal>() var tp = 1.toBigDecimal() stack@while(true) { if( tp > m ) break@stack //println(tp) bs.add( tp ) tp *= 2.toBigDecimal() } var x = 0.toBigDecimal() var control = false scan@while(true) { x++ if( bs.contains(x) ) continue@scan val y = n - x if( !bs.contains(y) ) { control = true break@scan } if( x > n/2.toBigDecimal() ) break@scan } if( control ) println("${x} ${n - x}") else println("-1") }