-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b552e3
commit 7e31773
Showing
2 changed files
with
95 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// @brief Discrete Logarithm | ||
#define PROBLEM "https://judge.yosupo.jp/problem/discrete_logarithm_mod" | ||
#pragma GCC optimize("Ofast,unroll-loops") | ||
#pragma GCC target("avx2,tune=native") | ||
#include "cp-algo/math/number_theory.hpp" | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
using namespace cp_algo; | ||
using namespace math; | ||
using base = dynamic_modint; | ||
|
||
void solve() { | ||
int x, y, m; | ||
cin >> x >> y >> m; | ||
auto res = discrete_log(x, y, m); | ||
if(res) { | ||
cout << *res << "\n"; | ||
} else { | ||
cout << -1 << "\n"; | ||
} | ||
} | ||
|
||
signed main() { | ||
//freopen("input.txt", "r", stdin); | ||
ios::sync_with_stdio(0); | ||
cin.tie(0); | ||
int t = 1; | ||
cin >> t; | ||
while(t--) { | ||
solve(); | ||
} | ||
} |