結果

問題 No.1462 最弱WEAKER
ユーザー c-yan
提出日時 2021-04-02 21:39:05
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 325 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 78,976 KB
最終ジャッジ日時 2024-12-23 18:39:34
合計ジャッジ時間 2,711 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 4 RE * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache
from math import log

N = int(input())

@lru_cache(maxsize=None)
def f(n):
    if n == 0:
        return True
    a = int(log(n, 3))
    for i in range(a + 1):
        if f(n - 3 ** i):
            continue
        return True
    return False

if f(N):
    print('YES')
else:
    print('NO')
0