結果
| 問題 | No.3501 Digit Products 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-19 03:51:03 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,382 bytes |
| 記録 | |
| コンパイル時間 | 2,019 ms |
| コンパイル使用メモリ | 215,988 KB |
| 実行使用メモリ | 30,320 KB |
| 平均クエリ数 | 4.73 |
| 最終ジャッジ日時 | 2026-04-19 03:51:42 |
| 合計ジャッジ時間 | 29,343 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 |
| other | AC * 7 RE * 65 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
vector<ll> f(ll n){
vector<ll> d;
for(ll i=1;i*i<=n;i++){
if(n%i==0){
d.push_back(i);
if(i!=n/i) d.push_back(n/i);
}
}
return d;
}
int main(void){
cin.tie(nullptr); ios_base::sync_with_stdio(false);
ll i,j;
ll N;
cin >> N;
vector<ll> v(N,-1);
ll c=0,p=-1,x=-1;
for(i=N-2;i>=0;i--){
cout << "? " << i << ' ' << N-1 << endl;
cout.flush();
c++;
cin >> p;
if(p==0){
v[i]=0;
continue;
}
else{
x=i;
break;
}
}
if(x==-1){
cout << "! " << -1 << endl;
cout.flush();
return 0;
}
vector<ll> e=f(p);
ll n=e.size();
vector<ll> u;
ll a=0;
bool g=true;
REP(i,n){
if(!(e[i]<=9 && p/e[i]<=9)) continue;
ll cc=c;
u=v;
u[N-1]=e[i];
u[x]=p/e[i];
bool f=true;
for(j=N-1;j>=0;j++){
if(u[j]!=-1) continue;
cout << "? " << j << ' ' << N-1 << endl;
cout.flush();
cc++;
ll q;
cin >> q;
if(q%v[N-1]==0) u[j]=q/v[N-1];
else{
f=false;
break;
}
}
if(!f) continue;
if(f && cc<=N){
a++;
if(a>=2){
g=false;
break;
}
}
}
if(g){
cout << "! ";
for(i=N-1;i>=0;i--) cout << u[i];
cout << endl;
cout.flush();
}
else{
cout << "! " << -1 << endl;
cout.flush();
}
return 0;
}