地址:http://acm.nyist.net/JudgeOnline/problem.php?pid=102 //a^b mod c=(a mod c)^b mod c很容易设计出一个基于二分的递归算法. #include<stdio.h> #include<stdlib.h> //快速幂算法,数论二分 long long powermod(int a,int b, int c) //不用longlong就报错,题目中那个取值范围不就在2的31次方内 { long long t;…
题目链接:https://loj.ac/problem/6392 题目大意:给定五个正整数c1,c2,e1,e2,N,其中e1与e2互质,且满足 c1 = m^e1 mod N c2 = m^e2 mod N 求出正整数m 解题思路:因为e1与e2互质,所以可以找到两个整数x,y,满足e1x+e2y=1 所以m^(e1x+e2y)=m^1=m=c1^x*c2^y; 注意如果x或者y小于0时,需要求c1.c2对N的逆元 因为N的范围很大,小于2的63次方,所以不能直接乘,需要用快速乘. 求逆元的时…
链接:https://www.nowcoder.com/acm/contest/106/B 来源:牛客网 题目描述 It's universally acknowledged that there're innumerable trees in the campus of HUST. One day Xiao Ming is walking on a straight road and sees many trees line up in the right side. Heights of e…