結果

問題 No.648  お や す み 
ユーザー Ytz_Ichi
提出日時 2020-02-18 23:53:15
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 413 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-10-06 15:56:04
合計ジャッジ時間 4,272 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
from decimal import *

getcontext().prec = 40
n = int(input())
drn = 1 + ((n - 1) % 9)
if drn == 1 or drn == 3 or drn == 6 or drn == 9:
    triangular = Decimal(8 * n + 1).sqrt()
    if triangular.quantize(Decimal("0"), rounding=ROUND_UP) == triangular.quantize(
        Decimal("0"), rounding=ROUND_DOWN
    ):
        print(f"YES\n{(int(triangular)-1)//2}")
        sys.exit()
print("NO")
0