Untitled

public
yousefkarem91 Jul 23, 2024 Never 61
Clone
C++ paste1.cpp 56 lines (52 loc) | 1.32 KB
1
#include<bits/stdc++.h>
2
using namespace std;
3
#define ll long long
4
#define all(d) d.begin(),d.end()
5
#define test int t;cin>>t;while(t--)
6
#define ones(n) __builtin_popcount(n)
7
#define last(n) ____builtin_clz(len)
8
const int dx8[8] = {1, 0, -1, 0,-1,-1,1,1};
9
const int dy8[8] = {0, 1, 0, -1, -1, 1, -1, 1};
10
int dx[] = {+0, +0, +1, -1};
11
int dy[] = {+1, -1, +0, +0};
12
char di[]={'R','L','D','U'};
13
void JOO() {
14
ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
15
#ifndef ONLINE_JUDGE
16
freopen("input.txt", "r", stdin);
17
freopen("output.txt", "w", stdout);
18
#endif
19
}
20
const int N=2e5+5,M=1e3,LOG=20,inf=0x3f3f3f3f;
21
int MOD=1e9+7;
22
ll infLL=0x3f3f3f3f3f3f3f3f;
23
24
ll mul(const ll &a, const ll &b) {
25
return (a % MOD + MOD) * (b % MOD + MOD) % MOD;
26
}
27
28
ll add(const ll &a, const ll &b) {
29
return (a + b + 2 * MOD) % MOD;
30
}
31
32
ll pw(ll b, ll p) {
33
if (p < 0)return 0;
34
if (!p) return 1LL;
35
ll ret = pw(b, p >> 1LL);
36
ret = mul(ret, ret);
37
if (p & 1LL)
38
ret = mul(ret, b);
39
return ret;
40
}
41
42
void solve()
43
{
44
ll n;cin>>n;
45
ll nio=mul(pw(3,n-1),add(1,-pw(pw(9,MOD-2),n/2)));
46
cout<<mul(nio,mul(9,pw(8,MOD-2)))<<'\n';
47
}
48
signed main() {
49
JOO();
50
// int cnt=1;
51
// test
52
{
53
// cout << "Case " << "#" << cnt++ << ": ";
54
solve();
55
}
56
}