题解:CF1737E Ela Goes Hiking
yuyue_is_not_human · · 题解
?!设计蚂蚁!?
假设序列死了。
钦定最右边🐜一定向左(向右也弹回来了),每只向左的🐜会先把向右的🐜吃掉,所以向右一定GG。
接下来,剩下一堆坦克🐜向左碾压而来,带走所有向右走的🐜(因为这些🐜不可能壮大自身,悲) 。
如果一只向左的🐜想要赢得胜利,至少……也要打赢……第一个对手吧……所以它需要带走尽可能多的右🐜。
记
同时,
这真是
记
直接转吧。
Code:
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1000010,p=1e9+7,iv=5e8+4;
int T,n,pw[N],ans[N],g,c;
signed main(){
ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
for(int i=pw[0]=1;i<=N-10;i++) pw[i]=pw[i-1]*iv%p;
cin>>T;while(T--){
cin>>n;g=1;c=n+1;
for(int i=n;i;i--){
int t1=(i-i/2-1),t2=i*2;
while(c>t2) c--,g=(g-ans[c]+p)%p;
int s=pw[t1];
if(i!=n) s=s*iv%p;
ans[i]=s*g%p;
}for(int i=1;i<=n;i++) cout<<ans[i]<<'\n';
}return 0;
}