逆元(名字太多人用我就加这几个字)

   日期:2020-11-16     浏览:144    评论:0    
核心提示:生活不易,我先叹气!诶,之前没懂逆元。“啊这题我咋wa了呜呜”xx:“因为你没会逆元”记录一下写题过程…51nod题目链接传送门一:逆元:还是别人写的好,妙啊哈哈哈,别人家的好博客费马小定理:费马小定理百度百科题意如上诶,我好菜#include <cstdio>#include <cstring>#include <string>#include <iostream>#include <cmath>#incl

生活不易,我先叹气!
诶,之前没懂逆元。
“啊这题我咋wa了呜呜”
xx:“因为你没会逆元”
记录一下写题过程…
51nod题目链接传送门
一:
逆元:
还是别人写的好,妙啊哈哈哈,别人家的好博客
费马小定理:
费马小定理百度百科


题意如上

诶,我好菜

#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll n;

ll qpow(ll x, ll y){ 
	ll res = 1;
	while(y){ 
		if(y & 1){ 
			res = res * x % mod;
		}
		y >>= 1;
		x = x * x % mod;
	}
	return res % mod;	
}

int main(){ 
	cin >> n;
	ll ans = 0;
	ans = (qpow(3, n + 1) - 1) % mod;
	ans *= qpow(2, mod - 2) % mod;
	ans %= mod;
	cout << ans << endl;
	return 0;
}

热血沸腾的去写了几题逆元的,5555555TLE了
震惊发现,我是傻逼 求逆元有几种方式,咳咳

 
打赏
 本文转载自:网络 
所有权利归属于原作者,如文章来源标示错误或侵犯了您的权利请联系微信13520258486
更多>最近资讯中心
更多>最新资讯中心
0相关评论

推荐图文
推荐资讯中心
点击排行
最新信息
新手指南
采购商服务
供应商服务
交易安全
关注我们
手机网站:
新浪微博:
微信关注:

13520258486

周一至周五 9:00-18:00
(其他时间联系在线客服)

24小时在线客服