https://codeforces.com/problemset/problem/1292/B
思路:
考虑最小的2倍也是指数了。因此答案最后100个点。且有一个贪心决策,优先跑左边的。
因为跑完左边的一串拿完也没有拿一个完整的区间段的右边来的花费时间多。
2^1+2^2<2^3
然后有一个问题,比如我起点很靠近右边的区间,这时候我要先拿右边的区间再往左边跑。如何处理。
暴力枚举起点拿当前第i个,如果顺路能拿别的也不考虑,一定能遍历到我们要的那个答案状态。然后往左跑,跑完了再往右跑
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=100;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar(); while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL a[maxn],b[maxn],tot=0;
bool vis[maxn];
int main(void)
{
cin.tie(0);std::ios::sync_with_stdio(false);
LL x0,y0,ax,ay,bx,by;cin>>x0>>y0>>ax>>ay>>bx>>by;
LL xs,ys,t;cin>>xs>>ys>>t;
tot++;
a[tot]=x0;b[tot]=y0;
while(tot<=70){
++tot;
LL nx=ax*a[tot-1]+bx;
LL ny=ay*b[tot-1]+by;
a[tot]=nx;
b[tot]=ny;
if( nx>xs&&ny>ys&&abs(nx-xs)+abs(ny-ys)>t ) break;
}
/* debug(tot);
for(LL i=1;i<=tot;i++){
cout<<a[i]<<" "<<b[i]<<"\n";
}*/
LL ans=0;
for(LL i=1;i<=tot;i++){///枚举人先拿i点的数据
LL temp=t;LL res=0;
if(abs(a[i]-xs)+abs(b[i]-ys)<=temp){
res++;
temp-=(abs(a[i]-xs)+abs(b[i]-ys));
}
else {ans=max(ans,res);continue;}
for(LL j=i-1;j>=1;j--){///先从Pi--->P0方向拿
if(abs(a[j]-a[j+1])+abs(b[j]-b[j+1])<=temp ){
res++;
temp-= ( abs(a[j]-a[j+1])+abs(b[j]-b[j+1]) );
}
else break;
}
for(LL j=1;j<=tot;j++){///从P0--->P∞方面拿
if(abs(a[j+1]-a[j])+abs(b[j+1]-b[j])<=temp){
temp-=( abs(a[j+1]-a[j])+abs(b[j+1]-b[j]) );
if(j>=i) res++;
}
else break;
}
ans=max(ans,res);
}
cout<<ans<<"\n";
return 0;
}