結果
| 問題 | No.3501 Digit Products 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-18 00:10:37 |
| 言語 | C++23(gnu拡張) (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,333 bytes |
| 記録 | |
| コンパイル時間 | 7,299 ms |
| コンパイル使用メモリ | 376,304 KB |
| 実行使用メモリ | 30,320 KB |
| 平均クエリ数 | 10.44 |
| 最終ジャッジ日時 | 2026-04-18 00:11:14 |
| 合計ジャッジ時間 | 17,585 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 18 WA * 21 RE * 33 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)
#define all(x) begin(x), end(x)
template <class T> bool chmin(T& x, T y) {
return x > y ? (x = y, true) : false;
}
template <class T> bool chmax(T& x, T y) {
return x < y ? (x = y, true) : false;
}
using mint = atcoder::modint998244353;
// isqrt
long long isqrt(long long n) {
if (n <= 0) return 0;
long long x = sqrt(n);
if (x * x > n) x--;
return x;
}
void solve() {
int n;
cin >> n;
int qn = 0;
auto query = [&](int a, int b) {
if (qn == n) {
cout << "! -1" << endl;
exit(0);
}
qn++;
if (a > b) swap(a, b);
cout << "? " << a << " " << b << endl;
int p;
cin >> p;
return p;
};
vector<int> v(n, -1);
rep(i, 0, n - 1) v[i] = query(i, n - 1);
vector<int> t;
rep(i, 0, n - 1) if (v[i] != 0) t.push_back(i);
if (t.size() < 2) {
cout << "! -1" << endl;
return;
}
int p = query(t[0], t[1]);
int tmp = p * v[t[0]] * v[t[1]];
int sq = isqrt(tmp);
assert(sq * sq == tmp);
v[n - 1] = sq / p;
rep(i, 0, n - 1) v[i] /= v[n - i];
cout << "! ";
rep(i, 0, n) cout << v[n - 1 - i];
cout << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
int t = 1;
// cin >> t;
while (t--) solve();
}