結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー 6soukiti296soukiti29
提出日時 2019-08-30 23:25:53
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 726 bytes
コンパイル時間 6,586 ms
コンパイル使用メモリ 68,204 KB
実行使用メモリ 5,528 KB
最終ジャッジ日時 2023-09-15 12:50:05
合計ジャッジ時間 37,446 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 765 ms
5,316 KB
testcase_06 AC 768 ms
5,336 KB
testcase_07 AC 765 ms
5,468 KB
testcase_08 WA -
testcase_09 AC 764 ms
5,472 KB
testcase_10 AC 765 ms
5,304 KB
testcase_11 AC 763 ms
5,352 KB
testcase_12 AC 762 ms
5,376 KB
testcase_13 AC 761 ms
5,336 KB
testcase_14 AC 773 ms
5,300 KB
testcase_15 AC 772 ms
5,280 KB
testcase_16 AC 771 ms
5,336 KB
testcase_17 AC 757 ms
5,288 KB
testcase_18 AC 761 ms
5,356 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 765 ms
5,344 KB
testcase_24 AC 772 ms
5,280 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 764 ms
5,372 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,strutils
var
    N = stdin.readline.parseInt
    A = newSeq[int](0)
    ans = ""
    dp = newSeqWith(300002, 100000000)
dp[0] = 0

for i in 0..300001:
    for j in 1..548:
        if i + j * j > 300001:
            break
        dp[i + j * j] = min(dp[i + j * j], dp[i] + 1)
        
while N > 0:
    var a : int
    var m : int = 1000000
    for i in 1..N:
        if N - i * i < 0:
            break
        if m > dp[N - i * i]:
            a = i
            m = dp[N - i * i]
    N -= a * a
    A.add(a)

for a in A:
    for i in 0..<a:
        if ans.len == 0:
            ans &= '0'
        elif i == 0:
            ans &= ans[^1]
        else:
            ans &= $(1 - (ans[^1].ord - '0'.ord))

echo ans
0