HDU 4602
来源:互联网 发布:windows重启网卡命令 编辑:程序博客网 时间:2024/05/22 09:04
a[1]=1;
a[2]=2;
a[n]=2*a[n-1]+2^(n-3)=2^2*a[n-2]+2*2^(n-3)=2^3a[n-3]+3*2^(n-3)=……=2^(n-2)a[2]+(n-2)*2^(n-3)=2^(n-1)+(n-2)*2^(n-3);
#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<queue>#include<string>using namespace std;#define lc l,m,index<<1#define rc m+1,r,index<<1|1#define ll long long#define mod 1000000007#define N 100005ll t,n,k;ll pm(ll x,ll y){ll ret=1,temp=x;while(y){if(y&1)ret=ret*temp%mod;temp=temp*temp%mod;y>>=1;}return ret;}int main(){scanf("%I64d",&t);while(t--){scanf("%I64d%I64d",&n,&k);if(n<k)printf("0\n");else{n=n-k+1;if(n==1)printf("1\n");else if(n==2)printf("2\n");else printf("%I64d\n",(pm(2,n-1)%mod+pm(2,n-3)*(n-2)%mod)%mod);}}return 0;}
- HDU-4602
- HDU 4602
- HDU 4602
- HDU 4602
- HDU 4602
- hdu - 4602 《Partition》
- HDU 4602 Partition
- HDU 4602 Partition
- hdu 4602 找规律
- hdu-4602-Partition
- hdu 4602 Partition
- hdu 4602题解
- HDU 4602 Partition
- hdu 4602 Partition
- hdu(4602) Partition
- hdu 4602 Partition
- HDU 4602 Partition
- hdu 4602 Partition
- Oracle undo 镜像数据探究
- 连连看java源代码
- BNU Box of Bricks
- C++中如何使类不能继承
- UVA 311 Packets(贪心 + 模拟)
- HDU 4602
- MyEclipse的优化与个性化设置方案
- Apache java项目全介绍
- escape和urldecode解码函数
- 完全卸载oracle11g步骤
- hdu 2601 An easy problem
- 关于CCTexure2D使用opengl实现绘制的原理分析
- 从1到n的数中找若干个数使其和为m
- 开始写社会化分享组件