結果
| 問題 |
No.1318 ABCD quadruplets
|
| コンテスト | |
| ユーザー |
tamato
|
| 提出日時 | 2020-12-15 10:57:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 762 ms / 2,000 ms |
| コード長 | 2,556 bytes |
| コンパイル時間 | 228 ms |
| コンパイル使用メモリ | 82,520 KB |
| 実行使用メモリ | 84,844 KB |
| 最終ジャッジ日時 | 2024-09-20 01:33:25 |
| 合計ジャッジ時間 | 8,949 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
mod = 1000000007
eps = 10**-9
def main():
import sys
input = sys.stdin.readline
def f(a, b, c, d):
return (a+b+c+d) ** 2 - (a+b) * (c+d) - a*b - c*d
N, M = map(int, input().split())
ans = [0] * (N+1)
for d in range(M+1):
if f(d+3, d+2, d+1, d) > N:
break
for c in range(d+1, M+1):
if f(c+2, c+1, c, d) > N:
break
for b in range(c+1, M+1):
if f(b+1, b, c, d) > N:
break
for a in range(b+1, M+1):
x = f(a, b, c, d)
if x > N:
break
ans[x] += 24
# d==c
for d in range(M+1):
if f(d+2, d+1, d, d) > N:
break
for b in range(d+1, M+1):
if f(b+1, b, d, d) > N:
break
for a in range(b+1, M+1):
x = f(a, b, d, d)
if x > N:
break
ans[x] += 12
# c==b
for d in range(M+1):
if f(d+2, d+1, d+1, d) > N:
break
for c in range(d+1, M+1):
if f(c+1, c, c, d) > N:
break
for a in range(c+1, M+1):
x = f(a, c, c, d)
if x > N:
break
ans[x] += 12
# b==a
for d in range(M+1):
if f(d+2, d+2, d+1, d) > N:
break
for c in range(d+1, M+1):
if f(c+1, c+1, c, d) > N:
break
for b in range(c+1, M+1):
x = f(b, b, c, d)
if x > N:
break
ans[x] += 12
# d==c, b==a
for d in range(M+1):
if f(d+1, d+1, d, d) > N:
break
for b in range(d+1, M+1):
x = f(b, b, d, d)
if x > N:
break
ans[x] += 6
# d==c==b
for d in range(M+1):
if f(d+1, d, d, d) > N:
break
for a in range(d+1, M+1):
x = f(a, d, d, d)
if x > N:
break
ans[x] += 4
# c==b==a
for d in range(M+1):
if f(d+1, d+1, d+1, d) > N:
break
for c in range(d+1, M+1):
x = f(c, c, c, d)
if x > N:
break
ans[x] += 4
#a==b==c==d:
for d in range(M+1):
x = f(d, d, d, d)
if x > N:
break
ans[x] += 1
print(*ans, sep="\n")
if __name__ == '__main__':
main()
tamato