結果
問題 |
No.648 お や す み
|
ユーザー |
|
提出日時 | 2018-02-19 13:36:19 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 642 bytes |
コンパイル時間 | 86 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 16,000 KB |
最終ジャッジ日時 | 2024-07-07 14:38:36 |
合計ジャッジ時間 | 17,648 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 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 の公式使ったもの""" if n == 1: print("OK") print("1") exit() for i in range(2, N+1): sum_sheep = i*(i+1)/2 if sum_sheep < n: continue elif sum_sheep == n: print("OK") print(i) exit() else: print("NG") exit() if __name__ == "__main__": n = int(input()) N = 2*(10**18) sum_one_to_n(n, N)