結果
| 問題 | No.3501 Digit Products 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-17 21:22:55 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,123 bytes |
| 記録 | |
| コンパイル時間 | 242 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 87,704 KB |
| 平均クエリ数 | 10.44 |
| 最終ジャッジ日時 | 2026-04-17 21:23:17 |
| 合計ジャッジ時間 | 16,956 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 27 WA * 12 RE * 33 |
ソースコード
# snippet: interactive_
# Last Modified: 2026-02-13
from collections import deque, defaultdict
from itertools import permutations, product
from bisect import bisect_left, bisect_right
from heapq import heappush, heappop
from random import randint, shuffle
def II(): return int(input())
def LI(): return list(map(int,input().split()))
def LI_1(): return [int(x) - 1 for x in input().split()]
def SI(): return input()
def LS(): return list(input().split())
mod = 998244353
inf = 1<<61
EPS = 10 ** -6
import sys
LOCAL = sys.stdin.isatty()
# snippet: isqrt_
# Last Modified: 2026-02-12
from math import sqrt
def isqrt(x):
y = int(sqrt(x))
while (y + 1) * (y + 1) <= x:
y += 1
while y * y > x:
y -= 1
return y
N = randint(2, 51)
X = str(randint(10 ** (N - 1), 10 ** N - 1))
A = [int(c) for c in X[::-1]]
if LOCAL:
def ask(*arg):
if arg[0] == "?":
_, a, b = arg
return A[a] * A[b]
_, x = arg
if x == X or x == "-1":
print("AC")
else:
print("WA")
print(X)
print(x)
return
else:
def ask(*arg):
print(*arg, flush=True)
if arg[0] == "?": return II()
return
def debug(*arg):
if LOCAL:
print(*arg, file=sys.stderr)
def solve():
N = II()
li = [0] * N
not_zero = []
for i in range(N - 1):
li[i] = ask("?", i, N - 1)
if li[i] != 0: not_zero.append((i, li[i]))
if sum(li) == 0:
ask("!", "-1")
elif len(not_zero) == 1:
i, x = not_zero[-1]
if x == 1 or x == 25 or x == 49 or x == 64 or x == 81:
ask("!", "".join(map(str, [isqrt(x) if j == i or j == 0 else li[~j] for j in range(N)])))
else:
ask("!", "-1")
else:
i, x = not_zero[-1]
j, y = not_zero[-2]
ij = ask("?", i, j)
a0 = isqrt(x * y // ij)
for i in range(N):
li[i] //= a0
li[-1] = a0
ask("!", "".join(map(str, li[::-1])))
return
if __name__ == "__main__":
T = 1
# T = II()
for _ in range(T):
solve()