Life is not easy, let me sigh first!
Hey, I didn't understand Ni Yuan before.
"Ah, what did I do with this question"
xx: "Because you didn't know
how to write the question " xx: "Because you don't know how to write the question " ...
51nod topic link portal
1: Nigen
: It
is better written by someone else, wonderful hahaha, other people's home Good blog
Fermat's little theorem:
Fermat's little theorem
The meaning of the title is as above
.
#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;
}
I went to write a few questions about the inverse element with enthusiasm, 5555555TLE
. I was shocked to find that I was a fool. There are several ways to find the inverse element.