結果
問題 |
No.1143 面積Nの三角形
|
ユーザー |
![]() |
提出日時 | 2025-08-06 22:56:45 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 877 bytes |
コンパイル時間 | 223 ms |
コンパイル使用メモリ | 12,032 KB |
実行使用メモリ | 10,368 KB |
最終ジャッジ日時 | 2025-08-06 22:56:47 |
合計ジャッジ時間 | 2,043 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 |
other | WA * 18 |
ソースコード
import math def count_triangles_with_area(N): triangles = set() # 最大辺を制限(面積Nなので辺の合計はある程度までで良い) max_len = 2 * N + 1 # 十分な上限(実験的に) for a in range(1, max_len): for b in range(a, max_len): # b >= a for c in range(b, max_len): # c >= b # 三角形の成立条件 if a + b > c: s = (a + b + c) / 2 area_squared = s * (s - a) * (s - b) * (s - c) if area_squared <= 0: continue area = math.sqrt(area_squared) if math.isclose(area, N, rel_tol=1e-9): # 三辺をソートしてセットに登録(合同除去) triangles.add((a, b, c)) return len(triangles)