結果
| 問題 | 
                            No.2142 Segment Zero
                             | 
                    
| コンテスト | |
| ユーザー | 
                             titia
                         | 
                    
| 提出日時 | 2022-12-02 22:36:09 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 75 ms / 2,000 ms | 
| コード長 | 243 bytes | 
| コンパイル時間 | 180 ms | 
| コンパイル使用メモリ | 81,840 KB | 
| 実行使用メモリ | 61,312 KB | 
| 最終ジャッジ日時 | 2024-10-10 00:10:47 | 
| 合計ジャッジ時間 | 3,153 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 35 | 
ソースコード
from math import sqrt
N,K=map(int,input().split())
SUM=0
ANS=2
for i in range(N,-1,-1):
    rest=K-SUM
    if rest<0:
        continue
    x=round((-1+sqrt(1+8*rest))/2)
    if x*(x+1)==rest*2 and x<i:
        ANS=1
    SUM+=i
print(ANS)
            
            
            
        
            
titia