結果
| 問題 | No.634 硬貨の枚数1 | 
| コンテスト | |
| ユーザー |  kurimupy | 
| 提出日時 | 2020-06-18 02:26:08 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 37 ms / 2,000 ms | 
| コード長 | 395 bytes | 
| コンパイル時間 | 103 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 11,264 KB | 
| 最終ジャッジ日時 | 2024-07-03 12:37:54 | 
| 合計ジャッジ時間 | 4,626 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 75 | 
コンパイルメッセージ
Main.py:4: SyntaxWarning: invalid decimal literal D = [x*(x+1)//2for x in range(1, 6000)]
ソースコード
#三角数定理、知らなかった...
import bisect
N = int(input())
D = [x*(x+1)//2for x in range(1, 6000)]
def is_good(N):
    return bisect.bisect_right(D,N)!=bisect.bisect_right(D,N-1)
def solve(N):
    if is_good(N):
        return 1
    else:
        for j in range(10**4):
            if N>j*(j+1)//2 and is_good(N-j*(j+1)//2):
                return 2
        return 3
print(solve(N))
            
            
            
        