結果
| 問題 | No.634 硬貨の枚数1 |
| コンテスト | |
| ユーザー |
kurimupy
|
| 提出日時 | 2020-06-18 02:26:08 |
| 言語 | Python3 (3.14.3 + numpy 2.4.2 + scipy 1.17.0) |
| 結果 |
AC
|
| 実行時間 | 147 ms / 2,000 ms |
| コード長 | 395 bytes |
| 記録 | |
| コンパイル時間 | 395 ms |
| コンパイル使用メモリ | 20,956 KB |
| 実行使用メモリ | 15,488 KB |
| 最終ジャッジ日時 | 2026-03-24 20:51:58 |
| 合計ジャッジ時間 | 11,811 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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))
kurimupy