結果
| 問題 | No.3501 Digit Products 2 |
| コンテスト | |
| ユーザー |
aorinngo0606
|
| 提出日時 | 2026-04-19 13:00:44 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,400 bytes |
| 記録 | |
| コンパイル時間 | 4,472 ms |
| コンパイル使用メモリ | 376,132 KB |
| 実行使用メモリ | 30,320 KB |
| 平均クエリ数 | 10.70 |
| 最終ジャッジ日時 | 2026-04-19 13:01:12 |
| 合計ジャッジ時間 | 15,147 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 |
| other | AC * 43 RE * 29 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
typedef long long ll;
typedef long double lb;
using namespace std;
using namespace atcoder;
#define all(x) (x).begin(), (x).end()
#define OVERLOAD_REP(_1, _2, _3, name, ...) name
#define REP1(i, n) for (auto i = std::decay_t<decltype(n)>{}; (i) != (n); ++(i))
#define REP2(i, l, r) for (auto i = (l); (i) != (r); ++(i))
#define rep(...) OVERLOAD_REP(__VA_ARGS__, REP2, REP1)(__VA_ARGS__)
template<class T> bool chmin(T& a, const T& b){if(a > b){a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b){if(a < b){a = b; return 1;} return 0;}
const ll INF = 1000000000000000000; // 10^18
int main(){
ll n;
cin >> n;
vector<ll> v(n-1);
ll non_zero_1 = -1;
ll non_zero_2 = -1;
string s = "! ";
//v[i] 10^n-1と10^iの積
for(int i = 0;i < n-1;i++){
cout << "? " << i << " " << n-1 << endl;
cin >> v[i];
if(v[i] != 0 && non_zero_1 == -1){
non_zero_1 = i;
}else if(v[i] != 0 && non_zero_2 == -1){
non_zero_2 = i;
}
}
vector<bool> d(9,true);
ll true_count = 9;
//d[i] : 10^n-1が、i+1であれば、true
for(int i = 1;i <= 9;i++){
rep(j,v.size()){
if(v[j] % (i) != 0){
d[i-1] = false;
true_count--;
break;
}
}
}
if(true_count == 1){
//cout << "! ";
ll nn = -1;
for(int i = 1;i <= 9;i++){
if(d[i-1] == true){
nn = i;
// cout << i;
s += to_string(i);
}
}
for(int i = n-2;i >= 0;i--){
// cout << v[i] / nn;
s += to_string(v[i]/nn);
}
//cout << endl;
}else if(non_zero_2 == -1){
cout << "! " << -1 << endl;
}else{
cout << "? " << non_zero_1 << " " << non_zero_2 << endl;
ll tmp;
cin >> tmp;
ll nn = (ll)sqrt((double)v[non_zero_1]*(double)v[non_zero_2]/(double)tmp);
//cout << "! " << nn;
s += to_string(nn);
for(int i = n-2;i >= 0;i--){
// cout << v[i] / nn;
s += to_string(v[i] / nn);
}
//cout << endl;
}
if(s.size() != n+2){
int t = n;
int x = 2/(t-n);
cout << x << endl;
}else{
cout << s << endl;
}
return 0;
}
aorinngo0606