Hdu-6467

 

思路:

列出表达式,利用组合数公式化简表达式,化简求出Sn,然后快速幂求解。

主要化简思路在纸上,字丑,勿喷。

Hdu-6467(快速幂+组合数求和)

 

 

#include<iostream>
#include<cstdio>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
LL Pow(LL x,LL n)
{
	LL tp=2,ans=1;
	while(n){
		if(n%2==1) ans=ans*x%MOD;
		x=x*x%MOD;
		n/=2;
	}
	return ans;
}
int main(void)
{
	LL n,ans;
	while(~scanf("%lld",&n)){
		ans=(((n-1)%MOD)*(Pow(2,n)%MOD)%MOD+1)%MOD;
		printf("%d\n",ans);
	}
	return 0;
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-14
  • 2022-01-19
  • 2022-12-23
  • 2021-12-17
猜你喜欢
  • 2021-11-18
  • 2021-06-02
  • 2021-08-14
  • 2022-01-22
  • 2021-11-07
  • 2021-06-16
  • 2022-12-23
相关资源
相似解决方案