Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/SuprDewd/CompetitiveProgramming
/ leg
Function
leg
code/mathematics/tonelli_shanks.cpp:2–5 ·
view source on GitHub ↗
Source
from the content-addressed store, hash-verified
1
#include
"mod_pow.cpp"
2
ll leg(ll a, ll p) {
3
if (a % p == 0) return 0;
4
if (p == 2) return 1;
5
return mod_pow(a, (p-1)/2, p) == 1 ? 1 : -1; }
6
ll tonelli_shanks(ll n, ll p) {
7
assert(leg(n,p) == 1);
8
if (p == 2) return 1;
Callers
2
tonelli_shanks
Function · 0.85
test
Function · 0.85
Calls
1
mod_pow
Function · 0.85
Tested by
1
test
Function · 0.68