結果
| 問題 |
No.3028 No.9999
|
| コンテスト | |
| ユーザー |
eve__fuyuki
|
| 提出日時 | 2025-02-21 22:30:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 991 bytes |
| コンパイル時間 | 2,271 ms |
| コンパイル使用メモリ | 198,724 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-02-21 22:30:16 |
| 合計ジャッジ時間 | 3,227 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
void fast_io() {
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
}
int eular_phi(int n) {
vector<int> primes;
int x = n;
for (int i = 2; i * i <= n; i++) {
if (x % i == 0) {
primes.push_back(i);
while (x % i == 0) {
x /= i;
}
}
}
if (x > 1) {
primes.push_back(x);
}
int res = n;
for (int p : primes) {
res /= p;
res *= (p - 1);
}
return res;
}
int pow_mod(long long a, int n, int mod) {
long long res = 1;
while (n) {
if (n & 1) {
res = (res * a) % mod;
}
a = (a * a) % mod;
n >>= 1;
}
return res;
}
int main() {
fast_io();
int n;
cin >> n;
int phi = eular_phi(n);
vector<int> divisors;
for (int i = 1; i * i <= phi; i++) {
if (phi % i == 0) {
divisors.push_back(i);
if (i * i != phi) {
divisors.push_back(phi / i);
}
}
}
sort(divisors.begin(), divisors.end());
for (int d : divisors) {
if (pow_mod(10, d, n) == 1) {
cout << d << endl;
return 0;
}
}
}
eve__fuyuki