Comments (8)
k-th log じゃなくて k-th root だよね (しかも n になってるし)
m が素数以外で解けるのかは知らない
x^k == a (mod p)
O(k^3 + k^2 log p) 系もあるけどここでやるのは p^(1/4) 系だよねたぶん
p が 10^9 まででケースが少ないと離散対数で解けてしまうので云々
from library-checker-problems.
O(p^{1/4+ε})だと下の制約で最悪ケース1secぐらいで丁度良いと思います。
pが合成数の場合の解法は考えたことないです。
問題概要
p_i, a_i, k_i について x^k=a_i (mod p_i) を満たすxを出力せよ。
ただし解が存在しなければ-1を出力せよ。
入力
Q
p_1 a_1 k_1
p_2 a_2 k_2
\vdots
p_{Q} a_{Q} k_{Q}
制約
Q < 5e3
p_i < 1e9
a_i < p_i
from library-checker-problems.
- (非本質ですが) https://judge.yosupo.jp/problem/sqrt_mod に合わせて Q -> T、a_i -> Yで、入力順はK, Y, P (かY, K, P) としたいです
- Pは素数でいいと思います
- 速度は測らないと謎ですが、そんなものな気がします
from library-checker-problems.
入力順、了解です。
Kの制約を忘れていました。
1<= K <= 1e9
のつもりでした。K=0を含めるかどうかはどうしましょうか。
X^K=1 mod Pの解にX=0,K=0を含めるかなど。
from library-checker-problems.
入れておいていいと思います -> K = 0
from library-checker-problems.
worst_caseでも100msで思ったより速いですね………
from library-checker-problems.
https://judge.yosupo.jp/submission/5840 出ちゃいけないものが出てます
from library-checker-problems.
解説です。
https://yukicoder.me/problems/no/981/editorial
from library-checker-problems.
Related Issues (20)
- [テストケース案] Cycle Detection (Directed) : long_cycle
- [誤植] Nim Product カンマ
- latex render seems broken in problem "Polynomial Root Finding (Mod 998244353)" HOT 1
- [テストケース案] Min Plus Convolution (Convex and Arbitrary)
- [問題案] Palindromes in Deque HOT 3
- [問題案] (Addition/Multiplication/Division of Hex Big Integers) HOT 1
- [問題案] Counting Square-free numbers HOT 2
- [テストケース案] Counting Primes HOT 6
- [問題案] composition of formal power series (Large), compositional_inverse_of_formal_power_series (Large) HOT 1
- [Problem proposal] Sum of Multiplicative Function HOT 6
- License file is broken
- [Problem proposal] Vertex Add Range Contour Max on Tree HOT 2
- [テストケース案] Matching on Bipartite Graph HOT 2
- テストケース追加(convolution mod 2^64)
- [機能案] library checker の双対 HOT 2
- [問題案] Point Set Tree Path Rooted Composite Sum HOT 4
- [Problem proposal] (Range Add Range Sum) HOT 4
- テストケース Range Chmin Chmax Add Range Sum HOT 3
- [問題案] Point Set Tree Path Composite Sum HOT 2
- 問題案:2変数 FPS operations HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from library-checker-problems.