N - Aroma's Search CodeForces - 1293D

As the title DIV2 D is concerned, this problem is not difficult. Title effect: treasure hunt within the predetermined time, the position of the i-th treasure a * x (i-1) + b, a * y (i-1) + b. Then given initial position xs, ys and time t seek re-let within the time t be able to find how many treasures.

answer:

The coordinates of two adjacent differential treasure must be minimal. So the answer must be a continuous set of coordinates. Note that the range of the data range of x is 2e16, a minimum of 2, so most will be more than 60 treasures, direct starting point for the end of violence on the line.

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1E3+7;
ll limit=2e16;
struct stu{
    ll x,y;
}arr[N];
ll dis(ll x,ll y){
    return (ll)abs(arr[x].x-arr[y].x)+(ll)abs(arr[x].y-arr[y].y);
}
int main()
{
    ll x0,y0,a1,a2,b1,b2;
    cin>>x0>>y0>>a1>>a2>>b1>>b2;
    ll xs,ys,t;
    cin>>xs>>ys>>t;
    arr[0].x=x0;
    arr[0].y=y0;
    int pos=1;
    ll x=x0,y=y0;
    for(ll i=1;i<=100;i++){
        x=x*a1+b1;
        y=y*a2+b2;
        if(x>=limit||y>=limit) break;
        arr[pos].x=x;
        arr[pos++].y=y;
    }
    ll ans=0;
    for(ll i=0;i<pos;i++){
        for(ll j=0;j<pos;j++){
            if(dis(i,j)+(ll)abs(xs-arr[i].x)+(ll)abs(ys-arr[i].y)<=t){
                if(j>i) ans=max(ans,j-i+1);
                else ans=max(ans,i-j+1);
            }

        }
    }
    cout<<ans<<endl;
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/Accepting/p/12241352.html