結果
| 問題 | No.3501 Digit Products 2 |
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2026-04-18 01:08:23 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 2,000 ms |
| コード長 | 1,558 bytes |
| 記録 | |
| コンパイル時間 | 3,849 ms |
| コンパイル使用メモリ | 358,656 KB |
| 実行使用メモリ | 30,308 KB |
| 平均クエリ数 | 10.89 |
| 最終ジャッジ日時 | 2026-04-18 01:08:40 |
| 合計ジャッジ時間 | 7,274 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 72 |
ソースコード
#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
VI a(n);
auto ask = [&](int i, int j) {
i = n - 1 - i;
j = n - 1 - j;
if (i > j) swap(i, j);
cout << "? " << i << ' ' << j << endl;
int p;
cin >> p;
return p;
};
int i1 = -1, i2 = -1;
for (int i = 1; i < n; i++) {
a[i] = ask(0, i);
if (a[i]) tie(i1, i2) = pair(i, i1);
}
if (i2 != -1) {
a[0] = sqrt(a[i1] * a[i2] / ask(i1, i2));
} else if (i1 != -1) {
if (a[i1] == 1) a[0] = 1;
else if (a[i1] == 25) a[0] = 5;
else if (a[i1] == 49) a[0] = 7;
else if (a[i1] == 64) a[0] = 8;
else if (a[i1] == 81) a[0] = 9;
}
if (!a[0]) {
cout << "! " << -1 << endl;
return 0;
}
rep(i, n) if (i) a[i] /= a[0];
cout << "! ";
rep(i, n) cout << a[i];
cout << endl;
}
Kude