結果
| 問題 |
No.2187 三立法和 mod 333
|
| コンテスト | |
| ユーザー |
sepa38
|
| 提出日時 | 2023-01-13 22:06:21 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 824 bytes |
| コンパイル時間 | 265 ms |
| コンパイル使用メモリ | 81,904 KB |
| 実行使用メモリ | 153,636 KB |
| 最終ジャッジ日時 | 2024-12-24 17:37:24 |
| 合計ジャッジ時間 | 26,555 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 33 |
ソースコード
import bisect
ls = [[] for i in range(333)]
for i in range(1, 4444):
x = i ** 3
ls[x%333].append(x*i)
lim = 4444 ** 4
ans = 0
a = int(input())
e3 = [i**3 for i in range(4445)]
e4 = [i**4 for i in range(4445)]
for i in range(1, 4444):
s3 = e3[i] + e3[i]
k = (a - s3) % 333
s4 = e4[i] + e4[i]
cnt = bisect.bisect_right(ls[k], lim-s4) - bisect.bisect_left(ls[k], e4[i])
cnt = max(cnt, 0)
ans += cnt * 3
if (e3[i] * 3) % 333 == a and (e4[i] * 3) <= lim:
ans -= 2
for j in range(i+1, 4444):
s3 = e3[i] + e3[j]
k = (a - s3) % 333
s4 = e4[i] + e4[j]
if s4 > lim:
break
cnt = bisect.bisect_right(ls[k], lim-s4) - bisect.bisect_left(ls[k], e4[j])
cnt = max(cnt, 0)
ans += cnt * 6
if (e3[i] + e3[j] * 2) % 333 == a and (e4[i] + e4[j] * 2) <= lim:
ans -= 3
print(ans)
sepa38