結果

問題 No.648  お や す み 
コンテスト
ユーザー tmsausa
提出日時 2018-04-12 13:52:20
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 290 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 524 ms
コンパイル使用メモリ 20,572 KB
実行使用メモリ 31,304 KB
最終ジャッジ日時 2026-03-13 17:30:13
合計ジャッジ時間 185,302 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25 TLE * 59
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import math

n = int(input())

s, t = 1, int(2e9)

def f(x):
    return int(x * (x + 1) / 2)

while(s + 1 != t):
    x = (s + t) // 2
    if f(x) == n:
        print("YES")
        print(x)
        break
    elif f(x) > n:
        t = x + 1
    else:
        s = x - 1
else:
    print("NO")
0