結果
| 問題 | No.3501 Digit Products 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-18 23:26:05 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 2,000 ms |
| コード長 | 1,288 bytes |
| 記録 | |
| コンパイル時間 | 1,414 ms |
| コンパイル使用メモリ | 179,268 KB |
| 実行使用メモリ | 30,320 KB |
| 平均クエリ数 | 10.89 |
| 最終ジャッジ日時 | 2026-04-18 23:26:13 |
| 合計ジャッジ時間 | 6,052 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 72 |
コンパイルメッセージ
main.cpp: In function 'int sqrt(ll)':
main.cpp:17:1: warning: control reaches end of non-void function [-Wreturn-type]
17 | }
| ^
ソースコード
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <cassert>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; ++i)
int sqrt(ll x)
{
for (int i = 1; i < 10; i++)
if (x == i * i)
return i;
}
int main()
{
ll n;
cin >> n;
vector<ll> res(n);
vector<ll> non_zero;
rep(i, n - 1)
{
cout << "? " << i << " " << n - 1 << endl;
cin >> res[i];
if (res[i] != 0)
non_zero.emplace_back(i);
}
if (non_zero.size() == 0)
{
cout << "! -1" << endl;
return 0;
}
if (non_zero.size() == 1)
{
ll ret = res[non_zero[0]];
if (ret == 1 || ret == 25 || ret == 49 || ret == 64 || ret == 81)
{
res[n-1] = ret;
}
else
{
cout << "! -1" << endl;
return 0;
}
} else {
cout << "? " << non_zero[0] << " " << non_zero[1] << endl;
ll res01;
cin >> res01;
res[n - 1] = res[non_zero[0]] * res[non_zero[1]] / res01;
}
ll a_back = sqrt(res[n - 1]);
cout << "! ";
rep(i, n)
{
ll num = res[n - 1 - i] / a_back;
cout << res[n - 1 - i] / a_back;
}
cout << endl;
}