結果
| 問題 | No.3501 Digit Products 2 |
| コンテスト | |
| ユーザー |
shobonvip
|
| 提出日時 | 2026-04-18 21:20:47 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 2,000 ms |
| コード長 | 2,326 bytes |
| 記録 | |
| コンパイル時間 | 4,066 ms |
| コンパイル使用メモリ | 275,372 KB |
| 実行使用メモリ | 30,320 KB |
| 平均クエリ数 | 10.89 |
| 最終ジャッジ日時 | 2026-04-18 21:21:13 |
| 合計ジャッジ時間 | 12,031 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 72 |
ソースコード
/**
author: shobonvip
created: 2026.04.18 21:11:41
**/
#include<bits/stdc++.h>
using namespace std;
//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/
/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/
typedef long long ll;
#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)
#define all(v) v.begin(), v.end()
template <typename T> bool chmin(T &a, const T &b) {
if (a <= b) return false;
a = b;
return true;
}
template <typename T> bool chmax(T &a, const T &b) {
if (a >= b) return false;
a = b;
return true;
}
template <typename T> T max(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
return ret;
}
template <typename T> T min(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
return ret;
}
template <typename T> T sum(vector<T> &a){
T ret = 0;
for (int i=0; i<(int)a.size(); i++) ret += a[i];
return ret;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n; cin >> n;
auto ask = [&](int x,int y) -> int {
if (x>y) swap(x,y);
cout << "? " << x << ' ' << y << endl;
int v; cin >> v;
return v;
};
vector<int> v(n-1);
rep(i,0,n-1) {
v[i] = ask(n-1,i);
}
if (max(v) == 0) {
cout << "!" << ' ' << -1 << endl;
return 0;
}
vector<int> ind;
rep(i,0,n-1) {
if (v[i] > 0) ind.emplace_back(i);
}
if ((int)ind.size() == 1) {
int cnt = 0;
rep(x,1,10) {
rep(y,1,10) {
if (x * y == v[ind.front()]) {
cnt++;
}
}
}
if (cnt > 1) {
cout << "!" << ' ' << -1 << endl;
return 0;
}
rep(x,1,10) {
rep(y,1,10) {
if (x * y == v[ind.front()]) {
vector<int> ans(n);
ans[n-1] = x;
rep(i,0,n-1) {
ans[i] = v[i] / x;
}
cout << "! ";
rrep(i,0,n) {
cout << ans[i];
}
cout << endl;
return 0;
}
}
}
}
// 特定可能
int w = ask(ind.front(), ind.back());
int tops = int(sqrt(v[ind.front()] * v[ind.back()] / w));
vector<int> ans(n);
ans[n-1] = tops;
rep(i,0,n-1) {
ans[i] = v[i] / tops;
}
cout << "! ";
rrep(i,0,n) {
cout << ans[i];
}
cout << endl;
}
shobonvip