CodeForces - 1292B. Aroma's Search (+ thinking violence)

Meaning of the questions:

He told a location of the point, the point after accordance X [I ] = X [I - . 1 ] * AX + BX ;, Y [I ] = Y [I - . 1 ] * AY + by the regular distribution, initially you stand in one location, every second can move in four directions, ask you to walk on the maximum number of points in t

Ideas:

By data we can find 2 64- had more than 1e16 is the range of t, so only a maximum of 64 points in the map

So we just need violence to obtain the coordinates of each point, and then enumerate the start and end points you are taking (only one direction to go consecutive points is certainly the best)

Determining the distance (origin come from an initial position to a distance from the start point plus end) is less than t can be obtained a maximum value is the answer ah

#include<iostream>
#include<algorithm>
#include<cmath>
 using namespace std;
 typedef long long ll;
 ll x[70],y[70];
 ll dis(ll x1,ll y1,ll x2,ll y2)
 {
     return abs(x1-x2)+abs(y1-y2);
 }
 int main ()
 {
     ll ax,ay,bx,by,xs,ys,t;
     int cnt=0;
     cin>>x[0]>>y[0]>>ax>>ay>>bx>>by;
     cin>>xs>>ys>>t;
     while(x[cnt]-xs<t&&y[cnt]-ys<t){
         cnt++;
         x[cnt]=x[cnt-1]*ax+bx;
         y [cnt] = y [cnt- 1 ] * ay + by;
     }
    int ans=0;
    for(int i=0;i<=cnt;i++){
        for(int j=i;j<=cnt;j++){
            if(j-i+1<=ans) continue;
            ll temp=min(dis(x[i],y[i],xs,ys),dis(x[j],y[j],xs,ys));
            temp+=dis(x[i],y[i],x[j],y[j]);
            if(temp<=t) ans=j-i+1;
        }
    }
    cout<<ans<<endl;
    return 0;
 }

 

Guess you like

Origin www.cnblogs.com/overrate-wsj/p/12293603.html