{"problem":{"name":"Tangent Addition Formula","description":{"content":"You are given a prime number $p$ and non-negative integers $a$ and $b$. Determine if there is an infinite sequence of non-negative integers $t = \\bigl(t(0), t(1), t(2), \\ldots)$ that satisfies all of ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":10000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc166_f"},"statements":[{"statement_type":"Markdown","content":"You are given a prime number $p$ and non-negative integers $a$ and $b$.\nDetermine if there is an infinite sequence of non-negative integers $t = \\bigl(t(0), t(1), t(2), \\ldots)$ that satisfies all of the following conditions.\n\n*   $0\\leq t(x) < p$ for every non-negative integer $x$.\n*   $t(x+y)\\bigl(1-t(x)t(y)\\bigr)\\equiv t(x)+t(y)\\pmod{p}$ for all non-negative integers $x$ and $y$.\n*   $t(a)=b$.\n\nYou have $T$ test cases to solve.\n\n## Constraints\n\n*   $1\\leq T\\leq 2\\times 10^5$\n*   $p$ is a prime number such that $1\\leq p\\leq 10^9$.\n*   $0\\leq a\\leq 10^{9}$\n*   $0\\leq b < p$\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$T$\n$\\text{case}_1$\n$\\vdots$\n$\\text{case}_T$\n\nEach test case is given in the following format:\n\n$p$ $a$ $b$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc166_f","tags":[],"sample_group":[["4\n11 1 0\n11 1 1\n11 1 3\n11 1 5","Yes\nNo\nNo\nYes\n\n*   For $p=11, a=1, b=0$, a constant sequence $t = (0,0,0,0,\\ldots)$ satisfies the conditions.\n*   For $p=11, a=1, b=5$, a sequence $t = (0,5,6,0,5,6,\\ldots)$ of period $3$ satisfies the conditions."],["5\n5 0 0\n5 1 1\n5 2 2\n5 3 3\n5 4 4","Yes\nNo\nYes\nYes\nNo"],["7\n2 3 1\n2 5 0\n5 0 1\n5 0 2\n7 1 4\n11 12345 5\n13 12345 5","Yes\nYes\nNo\nYes\nNo\nNo\nYes"]],"created_at":"2026-03-03 11:01:14"}}