题意:已知
求 F(n) mod 1000000007
题解:写这题要先复习一下高中的知识。
https://blog.youkuaiyun.com/Zhengggggg/article/details/88614975
然后有了这个还不够,还得在复习一下高中的求和公式。有错位相减法,裂项相消,
这里用错位相减法。
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#define ll long long
using namespace std;
ll mod = 1e9+7;
ll poww(ll a,ll p){
ll ans = 1,b = a;
while(p){
if(p&1==1){
ans*=b;
ans%=mod;
}
b = b*b%mod;
p>>=1;
}
return ans;
}
int main(){
ll n;
while(cin>>n){
ll a = ((n-1)%mod*poww(2,n)+1)%mod;
cout<<a<<endl;
}
}