結果

問題 No.2426 Select Plus or Minus
ユーザー chebrinko
提出日時 2023-08-18 21:42:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 584 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 60,160 KB
最終ジャッジ日時 2024-11-28 06:17:20
合計ジャッジ時間 4,214 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 35 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

ans = ''
for i in range(10000):
    if n % 2 == 0:
        n //= 2
        ans += '/'
    else:
        tmp1 = int(3 * n + 1)
        tmp2 = int(3 * n - 1)
        cnt1 = 0
        cnt2 = 0
        for i in range(64):
            cnt1 += tmp1 >> i & 1
        for i in range(64):
            cnt2 += tmp2 >> i & 1
        if cnt1 == 1:
            n = tmp1
            ans += '+'
        elif cnt2 == 1:
            n = tmp2
            ans += '-'
        else:
            n = tmp1
            ans += '+'
    if n == 1:
        break

print(i + 1)       
print(ans)
0