結果
問題 | No.3028 No.9999 |
ユーザー |
![]() |
提出日時 | 2025-02-21 21:52:01 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 4,000 ms |
コード長 | 929 bytes |
コンパイル時間 | 5,671 ms |
コンパイル使用メモリ | 438,972 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-02-21 21:52:08 |
合計ジャッジ時間 | 6,695 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;#include <atcoder/math>using namespace atcoder;#include <boost/multiprecision/cpp_int.hpp>typedef boost::multiprecision::cpp_int bint;int main(){ll N;cin >> N;if(N == 1){cout << 1 << '\n';exit(0);}auto euler_phi = [](ll n) {ll ret = n;for(ll i = 2; i * i <= n; i++) {if(n % i == 0) {ret -= ret / i;while(n % i == 0) n /= i;}}if(n > 1) ret -= ret / n;return ret;};ll e = euler_phi(N);vector<ll> todo;for (int i = 1; i * i <= e; i++) {if(e % i == 0){todo.push_back(i);if(e != i * i){todo.push_back(e / i);}}}ranges::sort(todo);for(ll v : todo){if(pow_mod(10, v, N) == 1){cout << v << '\n';break;}}return 0;}/*File : ~/yukicoder/528/B.cppDate : 2025/02/21Time : 21:36:29*/