题目
Description
Input
Output
Sample Input
2
Sample Output
2
Data Constraint
分析
-
自己打个暴力规律
代码
1 #include<iostream> 2 #define ll long long 3 using namespace std; 4 int n,a[10001],flag[10001]; 5 const int mod=1e9+7; 6 ll ans; 7 long long ksm(ll a,ll b) 8 { 9 ll x=a; 10 ans=1; 11 while (b) 12 { 13 if (b&1!=0) ans=(ans*x)%mod; 14 ans%=mod; 15 x*=x; 16 x%=mod; 17 b>>=1; 18 } 19 return ans; 20 } 21 int main () 22 { 23 cin>>n; 24 cout<<ksm(2,n-1)%mod; 25 }