結果
| 問題 | No.1318 ABCD quadruplets |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-02-11 02:44:41 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 832 bytes |
| 記録 | |
| コンパイル時間 | 538 ms |
| コンパイル使用メモリ | 82,440 KB |
| 実行使用メモリ | 84,496 KB |
| 最終ジャッジ日時 | 2026-02-11 02:44:47 |
| 合計ジャッジ時間 | 5,433 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 TLE * 1 -- * 19 |
ソースコード
import math
def f(n, m):
count = 0
for a in range(0, m + 1):
for b in range(0, m + 1):
for c in range(0, m + 1):
S = a + b + c
C = a*a + b*b + c*c + a*b + a*c + b*c
D = S*S - 4*(C - n)
if D < 0:
continue
sqrtD = int(math.isqrt(D))
if sqrtD * sqrtD != D:
continue
# possible roots
d1 = (-S + sqrtD) // 2
d2 = (-S - sqrtD) // 2
if (-S + sqrtD) % 2 == 0 and 0 <= d1 <= m:
count += 1
if d1 != d2 and (-S - sqrtD) % 2 == 0 and 0 <= d2 <= m:
count += 1
return count
n,m = map(int,input().split())
for i in range(0, n + 1):
print(f(i, m))
vjudge1