結果
| 問題 | No.3501 Digit Products 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-30 16:55:41 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 1,055 bytes |
| 記録 | |
| コンパイル時間 | 55 ms |
| コンパイル使用メモリ | 15,232 KB |
| 実行使用メモリ | 11,264 KB |
| 平均クエリ数 | 1.00 |
| 最終ジャッジ日時 | 2026-09-30 16:55:52 |
| 合計ジャッジ時間 | 10,210 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 72 |
ソースコード
import math
import sys
def quit():
print("! -1")
sys.exit(0)
def query(x, y):
print(f"? {x} {y}")
output = int(input())
if output == -1:
sys.exit()
return output
def solve(n: int):
assert 2 <= n
if n == 2:
if query(0, 1) == 1:
print("! 11")
else:
quit()
return
products = [query(i, n - 1) for i in range(n - 1)]
products.reverse()
gcd = products[0]
for product in products:
gcd = math.gcd(gcd, product)
if gcd == 0:
quit()
candidates = []
last_query = query(0, 1)
for first_digit in range(1, 10):
if gcd % first_digit != 0:
continue
trying = [first_digit]
trying.extend(product // first_digit for product in products)
if (
all(0 <= digit <= 9 for digit in trying)
and last_query != trying[-1] * trying[-2]
):
candidates.append(trying)
if len(candidates) != 1:
quit()
else:
print(f"! {candidates[0]}")