結果

問題 No.648  お や す み 
ユーザー kamome
提出日時 2020-04-19 00:05:28
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 371 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-10-04 00:33:03
合計ジャッジ時間 4,199 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 79 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

i=int(input())
x=1
def ds(n):
    return 2*n + 0.5
def s(n):
    return int(0.5*(n**2)+0.5*n)
while True:
    prev=x
    x=x-((s(x)-i)/ds(x)) # ニュートン法
    if abs(prev - x) < 0.1:
        break
x=int(x)
while True:
    if s(x)==i:
        print("YES")
        print(x)
        exit()
    elif s(x)>i:
        print("NO")
        exit()
    else:
        x=x+1
0