結果
問題 |
No.648 お や す み
|
ユーザー |
|
提出日時 | 2018-02-19 13:44:46 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 595 bytes |
コンパイル時間 | 240 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 16,128 KB |
最終ジャッジ日時 | 2024-07-07 14:51:33 |
合計ジャッジ時間 | 16,940 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 60 TLE * 1 -- * 23 |
ソースコード
# -*- coding: utf-8 -*- def simple(n, N): """ TLEします """ sum_sheep = 0 for i in range(1,N+1): sum_sheep += i if sum_sheep < n: continue elif sum_sheep == n: print("YES") print(i) exit() else: print("NO") exit() def sum_one_to_n(n, N): """ 1からnまでの和 = n*(n+1)/2 の公式使ったもの""" for i in range(1, N+1): sum_sheep = i*(i+1)/2 if sum_sheep < n: continue elif sum_sheep == n: print("YES") print(i) exit() else: print("NO") exit() if __name__ == "__main__": n = int(input()) N = 2*(10**18) sum_one_to_n(n, N)