結果
| 問題 |
No.8056 量子コンピュータで素因数分解 Easy
|
| ユーザー |
👑 |
| 提出日時 | 2024-01-05 23:50:42 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 922 bytes |
| コンパイル時間 | 6,349 ms |
| コンパイル使用メモリ | 382,812 KB |
| 実行使用メモリ | 42,636 KB |
| 平均クエリ数 | 0.04 |
| 最終ジャッジ日時 | 2024-09-27 19:11:44 |
| 合計ジャッジ時間 | 9,975 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 TLE * 1 -- * 24 |
ソースコード
#include <cassert> // assert
#include <cstdlib> // exit
#include <iostream> // cin, cout, ios
#include <utility> // swap
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/miller_rabin.hpp>
#include <boost/random/mersenne_twister.hpp>
namespace mp = boost::multiprecision;
using bigint = mp::cpp_int;
void check(bigint n, bigint v) {
bigint g = mp::gcd(v, n);
if(g > (bigint)2 && g < n) {
std::cout << "! " << g << " " << n / g << '\n';
std::exit(0);
}
}
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
boost::random::mt19937 gen;
bigint n, r;
std::cin >> n;
check(n, (bigint)3);
for(int a = 2;; a += 1) {
check(n, (bigint)a);
std::cout << "? " << a << '\n';
std::cin >> r;
if((r & (bigint)1) == (bigint)0) {
r >>= 1;
}
for(int b = 0; b < 99; b += 1) {
check(n, mp::powm(a + (bigint)b, r, n) - (bigint)1);
}
}
}