結果
問題 | No.688 E869120 and Constructing Array 2 |
ユーザー | むらため |
提出日時 | 2019-01-17 17:29:35 |
言語 | Nim (2.0.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 600 bytes |
コンパイル時間 | 3,007 ms |
コンパイル使用メモリ | 68,392 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-14 02:03:12 |
合計ジャッジ時間 | 3,266 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 1 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 1 ms
4,380 KB |
testcase_11 | AC | 1 ms
4,380 KB |
testcase_12 | AC | 1 ms
4,384 KB |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport] /home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'algorithm' [UnusedImport]
ソースコード
import sequtils,strutils,algorithm,math,bitops # a:0 b:1 で合計が2となるのがちょうどK通り # 2^a * bC2 == k なる aとbを求める :: bC2 = b!/2!/(b-2)! = b*(b-1)/2 let k = stdin.readLine().parseInt() proc factorOf2(n:int):int = n and -n let maxA = k.factorOf2().countTrailingZeroBits() for a in 0..maxA: let c = k div (1 shl a) let d = 1 + 8 * c let dsqrt = d.float.sqrt.int if dsqrt * dsqrt != d : continue if (1 + dsqrt) mod 2 == 1 : continue let b = (1 + dsqrt) div 2 if a + b > 30 : continue echo a + b echo ("0".repeat(a) & "1".repeat(b)).join(" ") quit(0)