Skip to content

Commit 1b751da

Browse files
committed
solved 15717
1 parent 8a9abc5 commit 1b751da

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

15000/15717/15717.cpp

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
typedef long long ll;
5+
6+
ll n;
7+
int mod = 1000000007;
8+
9+
int main() {
10+
ios::sync_with_stdio(false); cin.tie(NULL);
11+
cin>>n;
12+
--n;
13+
14+
ll ans = 1, cur = 2;
15+
if(n == 0){
16+
ans = 1;
17+
}
18+
19+
while(n > 0){
20+
if(n % 2) {
21+
ans = (ans*cur) % mod;
22+
n--;
23+
}else {
24+
n /= 2;
25+
cur = (cur*cur) % mod;
26+
}
27+
}
28+
29+
cout<<ans<<"\n";
30+
return 0;
31+
}

0 commit comments

Comments
 (0)