結果

問題 No.1462 最弱WEAKER
ユーザー c-yanc-yan
提出日時 2021-04-02 21:47:42
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 390 bytes
コンパイル時間 373 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-12-23 19:00:59
合計ジャッジ時間 1,735 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 RE * 2
other AC * 4 RE * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import setrecursionlimit
from functools import lru_cache
from math import log

setrecursionlimit(10 ** 6)

N = int(input())

@lru_cache(maxsize=1000000)
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