Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
29330 | LYLAKIOI | 【BJ】T1 | C++ | 通过 | 100 | 21 MS | 11728 KB | 835 | 2024-05-06 14:35:38 |
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define p_b push_back #define p1 first #define p2 second using namespace std; typedef long long ll; const int maxn=1e6+10,mod=1e9+7; inline ll read(){ ll x=0;short t=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; }int n,pw[maxn],dp[maxn],sum[maxn]; void slv(){ n=read();pw[0]=1;up(i,1,n)pw[i]=pw[i-1]*2ll%mod; dp[n]=sum[n]=2; down(i,n-1,1)dp[i]=(sum[i+1]-sum[min((i<<1)-1,n)+1]+mod)%mod,sum[i]=(sum[i+1]+dp[i])%mod; int res=0; up(i,1,n)(res+=dp[i]*1ll*pw[i/2]%mod*1ll*i%mod)%=mod;cout<<res; }int main(){ slv(); fclose(stdin); fclose(stdout); return 0; }