提出 #73502409
ソースコード 拡げる
from collections import deque
M,A,B = map(int,input().split())
X = [[False]*M for _ in range(M)]
Y = [[[]*M for _ in range(M)] for _ in range(M)]
for i in range(M):
for j in range(M):
Y[j][(A*j+B*i)%M].append((i,j))
q = deque()
for i in range(M):
X[i][0] = True
q.append((i,0))
while q:
a,b = q.popleft()
for i,j in Y[a][b]:
if not X[i][j]:
X[i][j] = True
q.append((i,j))
ans = 0
for i in range(1,M):
for j in range(1,M):
if not X[i][j]:
ans += 1
print(ans)
提出情報
| 提出日時 | |
|---|---|
| 問題 | E - Multiple-Free Sequences |
| ユーザ | glaceon1020 |
| 言語 | Python (PyPy 3.11-v7.3.20) |
| 得点 | 450 |
| コード長 | 563 Byte |
| 結果 | AC |
| 実行時間 | 507 ms |
| メモリ | 247668 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 450 / 450 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt |
| All | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, 01-32.txt, 01-33.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00-sample-01.txt | AC | 66 ms | 93624 KiB |
| 00-sample-02.txt | AC | 114 ms | 117468 KiB |
| 00-sample-03.txt | AC | 265 ms | 170660 KiB |
| 01-01.txt | AC | 68 ms | 93868 KiB |
| 01-02.txt | AC | 66 ms | 93360 KiB |
| 01-03.txt | AC | 66 ms | 93748 KiB |
| 01-04.txt | AC | 65 ms | 93672 KiB |
| 01-05.txt | AC | 219 ms | 190524 KiB |
| 01-06.txt | AC | 174 ms | 178132 KiB |
| 01-07.txt | AC | 502 ms | 247080 KiB |
| 01-08.txt | AC | 504 ms | 245584 KiB |
| 01-09.txt | AC | 507 ms | 247668 KiB |
| 01-10.txt | AC | 451 ms | 227380 KiB |
| 01-11.txt | AC | 146 ms | 151544 KiB |
| 01-12.txt | AC | 146 ms | 152040 KiB |
| 01-13.txt | AC | 212 ms | 174868 KiB |
| 01-14.txt | AC | 183 ms | 174184 KiB |
| 01-15.txt | AC | 132 ms | 145308 KiB |
| 01-16.txt | AC | 130 ms | 145916 KiB |
| 01-17.txt | AC | 159 ms | 145612 KiB |
| 01-18.txt | AC | 151 ms | 145616 KiB |
| 01-19.txt | AC | 108 ms | 116220 KiB |
| 01-20.txt | AC | 106 ms | 116404 KiB |
| 01-21.txt | AC | 102 ms | 116340 KiB |
| 01-22.txt | AC | 159 ms | 152184 KiB |
| 01-23.txt | AC | 165 ms | 153652 KiB |
| 01-24.txt | AC | 168 ms | 152144 KiB |
| 01-25.txt | AC | 441 ms | 217944 KiB |
| 01-26.txt | AC | 107 ms | 117180 KiB |
| 01-27.txt | AC | 334 ms | 201656 KiB |
| 01-28.txt | AC | 192 ms | 169848 KiB |
| 01-29.txt | AC | 112 ms | 117320 KiB |
| 01-30.txt | AC | 416 ms | 227416 KiB |
| 01-31.txt | AC | 494 ms | 247616 KiB |
| 01-32.txt | AC | 274 ms | 227516 KiB |
| 01-33.txt | AC | 296 ms | 227744 KiB |