結果
| 問題 |
No.2847 Birthday Attack
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-23 22:30:14 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 817 bytes |
| コンパイル時間 | 337 ms |
| コンパイル使用メモリ | 82,480 KB |
| 実行使用メモリ | 294,688 KB |
| 最終ジャッジ日時 | 2024-08-23 22:30:32 |
| 合計ジャッジ時間 | 7,206 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | WA * 1 TLE * 1 -- * 12 |
ソースコード
from math import gcd
x, y, MOD = map(int, input().split())
ans = 0
lst = []
for n in range(1, 4000000):
for m in range(n + 1, 4000000):
a = m * m - n * n
b = 2 * m * n
c = m * m + n * n
if b > max(x, y):
break
if gcd(a, b, c) == 1:
lst.append((a, b, c))
ans = 0
ox = x // 2
ex = x - ox
oy = y // 2
ey = y - oy
ans += ox * (ox - 1) // 2 * y
ans += ex * (ex - 1) // 2 * y
ans += oy * (oy - 1) // 2 * x
ans += ey * (ey - 1) // 2 * x
ans %= MOD
print(2 * ans % MOD)
exit()
for a, b, c in lst:
k = min(x // a, y // b)
for i in range(1, k + 1):
ans += (x - a * i) * (y - b * i) % MOD
k = min(x // b, y // a)
for i in range(1, k + 1):
ans += (x - b * i) * (y - a * i) % MOD
ans %= MOD
ans *= 2
print(ans % MOD)