結果
| 問題 | No.3501 Digit Products 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-18 04:14:01 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,225 bytes |
| 記録 | |
| コンパイル時間 | 1,441 ms |
| コンパイル使用メモリ | 170,536 KB |
| 実行使用メモリ | 30,320 KB |
| 平均クエリ数 | 10.44 |
| 最終ジャッジ日時 | 2026-04-18 04:14:11 |
| 合計ジャッジ時間 | 8,273 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 70 WA * 2 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
int N;
cin >> N;
vector<long long> P(N - 1);
for (int i = 0; i < N - 1; ++i) {
cout << "? " << i << " " << N - 1 << endl;
cin >> P[i];
if (P[i] == -1) return 0;
}
vector<string> candidates;
for (int k = 1; k <= 9; ++k) {
string current_x = "";
bool ok = true;
for (int i = 0; i < N - 1; ++i) {
if (P[i] % k != 0 || P[i] / k > 9) {
ok = false;
break;
}
current_x += to_string(P[i] / k);
}
if (ok) {
string full_x = "";
full_x += to_string(k);
for (int i = N - 2; i >= 0; --i) {
full_x += current_x[i];
}
string candidate = "";
candidate += to_string(k);
for(int i = N - 2; i >= 0; --i) {
candidate += to_string(P[i] / k);
}
candidates.push_back(candidate);
}
}
if (candidates.size() == 1) {
cout << "! " << candidates[0] << endl;
} else {
cout << "! -1" << endl;
}
return 0;
}