結果
| 問題 |
No.8056 量子コンピュータで素因数分解 Easy
|
| ユーザー |
👑 |
| 提出日時 | 2024-01-05 23:39:52 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 958 bytes |
| コンパイル時間 | 7,159 ms |
| コンパイル使用メモリ | 385,496 KB |
| 実行使用メモリ | 43,408 KB |
| 平均クエリ数 | 0.04 |
| 最終ジャッジ日時 | 2024-09-27 19:11:33 |
| 合計ジャッジ時間 | 8,781 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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(bigint a = (bigint)2; a < n; a += (bigint)1) {
check(n, a);
std::cout << "? " << a << '\n';
std::cin >> r;
if((r & (bigint)1) == (bigint)0) {
r >>= 1;
}
for(bigint b = (bigint)0; b < (bigint)99; b += (bigint)1) {
check(n, mp::powm(a + b, r, n) - (bigint)1);
}
}
}