简单数学题 (HDU6467)

题目链接  http://acm.hdu.edu.cn/showproblem.php?pid=6467 

简单数学题 (HDU6467)_第1张图片

 

 

 简单数学题 (HDU6467)_第2张图片

 

倒数第三行改成F(n)-(n-1)*2^n=F(n-1)-(n-2)*2^(n-1) 

 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
typedef long long ll;
const int MAX=1E9+7;;
const int MM=192600817;
deque  dq;
int f(ll a,ll b)
{
    ll ans=1;
    a%=MAX;
    while(b)
    {
        if(b&1)
            ans=a*ans%MAX;
        a=a*a%MAX;
        b>>=1;
    }
    return ans%MAX;
}
int main()
{
    ll n,ans;
    while(cin>>n)
    {
        ans=(((n-1)%MAX)*(f(2,n)%MAX)+1)%MAX;
        cout<

 

你可能感兴趣的:(个人赛)