結果

問題 No.3522 冪乗乗
コンテスト
ユーザー Carpenters-Cat
提出日時 2026-05-02 01:03:19
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 604 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,471 ms
コンパイル使用メモリ 444,344 KB
実行使用メモリ 30,320 KB
平均クエリ数 30.90
最終ジャッジ日時 2026-05-02 01:03:36
合計ジャッジ時間 9,111 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 63
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
int main () {
	ll n, m, l;
	cin >> n >> m >> l;
	ll ng = 0, ok = (ll)1e9 + 1;
	while (abs(ok - ng) > 1) {
		ll mu = (ok + ng) / 2;
		ll x;
		cout << "? " << mu << " 1" << endl;
		cin >> x;
		if (mu == x) {
			ng = mu;
		} else {
			ok = mu;
		}
	}
	mp::cpp_int ml = 1;
	for (int i = 0; i < l; i ++) ml *= m;
	ll ans = 1; n %= ok;
	while (ml) {
		if (ml & 1) {
			ans = (ans * n) % ok;
		}
		ml>>= 1;
		n = (n * n) % ok;
	}
	cout << "! " << ans << endl;
}
0