http://codeforces.com/problemset/problem/992/C
Meaning of the questions:
Give you two numbers x, k, k k + 1 representatives month, x can be doubled every month, the month after an increase at the beginning of a 50% chance x minus 1, an increase of k + 1 month after the result is divided by the sum of the number of species in each case.
The subject of the request is the result of growth k + 1 month after.
We can launch his growth process according to the third sample
3
6 5
12 11 10 9
| | | |
24 22 20 18
From this we deduce easily draw each case the resulting constitute a arithmetic sequence, with a tolerance of 2
The results are: (2-n-*. 1) * 2 K + 1'd
Note that special circumstances sentence 0, 0 when the answer is 0, direct output
Also seeking a power of 2, when rapid power, pay attention to take the remainder
1 #include <stdio.h> 2 #include <string.h> 3 #include <iostream> 4 #include <string> 5 #include <math.h> 6 #include <algorithm> 7 #include <vector> 8 #include <stack> 9 #include <queue> 10 #include <set> 11 #include <map> 12 #include <sstream> 13 const int INF=0x3f3f3f3f; 14 typedef long long LL; 15 const int mod=1e9+7; 16 //const double PI=acos(-1); 17 #define Bug cout<<"---------------------"<<endl 18 const int maxm=1e6+10; 19 const int maxn=1e5+10; 20 using namespace std; 21 22 LL POW(LL a,LL b ) 23 { 24 LL ans = 1; 25 a = a % mod; 26 while(b) 27 { 28 if( b % 2 == 1 ) 29 ans = ( ans * a ) % mod; 30 a = ( a * a ) % mod; 31 b /= 2; 32 } 33 return ans; 34 } 35 36 int main() 37 { 38 LL n,k; 39 scanf("%lld %lld",&n,&k); 40 LL ans=0; 41 if(n!=0) 42 { 43 n=n%mod; 44 ans=(((2*n-1)*POW(2,k)+mod)%mod+1+mod)%mod; 45 } 46 printf("%d\n",ans); 47 return 0; 48 }