题目链接 欧拉定理: 当\(a\),\(m\)互质时,\(a^{\phi(m)}\equiv 1 (mod ~ m)\) 扩展欧拉定理: 当\(B>\phi(m)\)时,\(a^B\equiv a^{B~mod~\phi(m)+\phi(m)}\) #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #define int long long using names…
Description has only two Sentences Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 124 Accepted Submission(s): 55 Problem Description an = X*an-1 + Y and Y mod (X-1) = 0.Your task is to calculat…
P3811 [模板]乘法逆元 题意 求1-n所有整数在模p意义下的逆元. 分析 逆元 如果x满足\(ax=1(\%p)\)(其中a p是给定的数)那么称\(x\)是在\(%p\)意义下\(a\)的逆元 A 拓展欧几里得算法 \[ax=1(\%p)\] 转换一下也就是 \[ax+py=1\] #include<bits/stdc++.h> using namespace std; typedef long long ll; int extgcd(int a,int b,int&x,int…
The Luckiest number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 980 Accepted Submission(s): 301 Problem Description Chinese people think of '8' as the lucky digit. Bob also likes digit '8…