結果

問題 No.648  お や す み 
ユーザー はむ吉🐹
提出日時 2018-02-09 23:09:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 512 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 80,284 KB
最終ジャッジ日時 2024-09-13 21:04:16
合計ジャッジ時間 13,009 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env pypy3

import decimal
import math


def solve(n):
    n0 = decimal.Decimal(n)
    in_sq = 8 * n0 + 1
    sq_r = math.floor(math.sqrt(in_sq))
    if sq_r * sq_r != in_sq:
        return None
    d, m = divmod(sq_r - 1, 2)
    if m != 0:
        return None
    else:
        return int(d)


def main():
    decimal.getcontext().prec = 30
    res = solve(int(input()))
    if res is None:
        print("NO")
    else:
        print("YES")
        print(res)


if __name__ == '__main__':
    main()
0