結果
| 問題 | No.3501 Digit Products 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-18 15:18:45 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,226 bytes |
| 記録 | |
| コンパイル時間 | 3,567 ms |
| コンパイル使用メモリ | 333,248 KB |
| 実行使用メモリ | 30,320 KB |
| 平均クエリ数 | 4.70 |
| 最終ジャッジ日時 | 2026-04-18 15:19:12 |
| 合計ジャッジ時間 | 23,822 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 |
| other | AC * 14 WA * 2 RE * 56 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
long long ask(int a, int b) {
cout << "? " << a << " " << b << endl;
cout.flush();
long long x;
cin >> x;
if (x == -1) exit(0);
return x;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
vector<long long> d(N);
int i = 0;
while (i + 2 < N) {
long long ab = ask(i, i+1);
long long ac = ask(i, i+2);
long long bc = ask(i+1, i+2);
long long A = sqrt((ab * ac) / bc);
long long B = ab / A;
long long C = ac / A;
d[i] = A;
d[i+1] = B;
d[i+2] = C;
i += 3;
}
// Handle remaining 1 or 2 digits
if (i < N) {
// Use previous digit if exists
if (i > 0) {
long long p = ask(i-1, i);
d[i] = p / d[i-1];
} else {
// N = 1 edge (not possible here since N ≥ 2)
}
}
if (i + 1 < N) {
long long p = ask(i, i+1);
d[i+1] = p / d[i];
}
// Build number
long long X = 0, pw = 1;
for (int i = 0; i < N; i++) {
X += d[i] * pw;
pw *= 10;
}
cout << "! " << X << endl;
cout.flush();
}