結果
| 問題 | No.3501 Digit Products 2 |
| コンテスト | |
| ユーザー |
Tehom
|
| 提出日時 | 2026-04-17 23:05:39 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 2,067 bytes |
| 記録 | |
| コンパイル時間 | 3,538 ms |
| コンパイル使用メモリ | 274,920 KB |
| 実行使用メモリ | 30,308 KB |
| 平均クエリ数 | 11.34 |
| 最終ジャッジ日時 | 2026-04-17 23:06:07 |
| 合計ジャッジ時間 | 10,172 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 72 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repl(i,a,b) for(ll i=(a);i<(b);i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
template <typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;} return false;}
template <typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;} return false;}
void solve(){
int n; cin >> n;
int l=-1,lx=-1;
int r=-1,rx=-1;
vector<int> ans(n,-1);
int now=n-2;
bool can=true;
while(1){
cout << "? " << now << " " << n-1 << endl;
int x; cin >> x;
if(x == 0){
ans[now]=0;
now--;
}
else{
if(l == -1){
l=now;
lx=x;
now--;
}
else if(r == -1){
r=now;
rx=x;
cout << "? " << r << " " << l << endl;
int y; cin >> y;
ans[n-1]=sqrt(lx*rx/y);
ans[l]=lx/ans[n-1];
ans[r]=rx/ans[n-1];
now--;
}
else{
ans[now]=x/ans[n-1];
now--;
}
}
if(now == -1){
if(ans[n-1] == -1){
if(l != -1){
cout << "? " << l << " " << n-1 << endl;
int x; cin >> x;
bool can=false;
rep(i,1,10)rep(j,1,10){
if(i*j == x){
if(i != j){
cout << "! " << -1 << endl;
return;
}
ans[l]=ans[n-1]=i;
can=true;
}
}
if(can){
cout << "! ";
for(int i=n-1;i>=0;i--){
cout << ans[i];
}
cout << endl;
}
else cout << "! " << -1 << endl;
}
else cout << "! -1" << endl;
}
else{
cout << "! ";
for(int i=n-1;i>=0;i--){
cout << ans[i];
}
cout << endl;
}
return;
}
}
return;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T=1;
// cin >> T;
while(T--) solve();
}
Tehom