結果

問題 No.1185 完全な3の倍数
ユーザー soc-3soc-3
提出日時 2022-03-10 17:07:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 366 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 71,636 KB
最終ジャッジ日時 2023-10-12 19:28:43
合計ジャッジ時間 4,843 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 72 ms
71,184 KB
testcase_02 AC 73 ms
71,368 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 71 ms
71,328 KB
testcase_09 AC 70 ms
71,256 KB
testcase_10 AC 71 ms
71,472 KB
testcase_11 AC 72 ms
71,212 KB
testcase_12 AC 70 ms
71,292 KB
testcase_13 AC 72 ms
71,404 KB
testcase_14 AC 72 ms
71,184 KB
testcase_15 AC 72 ms
71,188 KB
testcase_16 AC 72 ms
71,088 KB
testcase_17 AC 72 ms
71,380 KB
testcase_18 AC 70 ms
71,392 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
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 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 72 ms
71,196 KB
testcase_40 AC 72 ms
71,064 KB
testcase_41 AC 73 ms
71,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

if len(str(n)) <= 2:
    print(n // 3 - 3)
    exit()

ans = 30 - 15
tmp = ""
cnt = 0
for i in str(n):
    if int(i) % 3 != 0:
        tmp += str(int(i) + (3 - int(i) % 3))
    else:
        cnt += 1
        tmp += i

for i, j in enumerate(tmp[::-1]):
    ans += int(j) // 3 * (4 ** i)
if cnt == len(str(n)):
    print(ans)
else:
    print(ans - 1)
0