Aroma's Search(暴力)

THE SxPLAY & KIVΛ - 漂流
KIVΛ & Nikki Simmons - Perspectives
With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space.

The space can be considered a 2D plane, with an infinite number of data nodes, indexed from 00, with their coordinates defined as follows:

The coordinates of the 00-th node is (x0,y0)(x0,y0)
For i>0i>0, the coordinates of ii-th node is (ax⋅xi−1+bx,ay⋅yi−1+by)(ax⋅xi−1+bx,ay⋅yi−1+by)
Initially Aroma stands at the point (xs,ys)(xs,ys). She can stay in OS space for at most tt seconds, because after this time she has to warp back to the real world. She doesn’t need to return to the entry point (xs,ys)(xs,ys) to warp home.

While within the OS space, Aroma can do the following actions:

From the point (x,y)(x,y), Aroma can move to one of the following points: (x−1,y)(x−1,y), (x+1,y)(x+1,y), (x,y−1)(x,y−1) or (x,y+1)(x,y+1). This action requires 11 second.
If there is a data node at where Aroma is staying, she can collect it. We can assume this action costs 00 seconds. Of course, each data node can be collected at most once.
Aroma wants to collect as many data as possible before warping back. Can you help her in calculating the maximum number of data nodes she could collect within tt seconds?

Input
The first line contains integers x0x0, y0y0, axax, ayay, bxbx, byby (1≤x0,y0≤10161≤x0,y0≤1016, 2≤ax,ay≤1002≤ax,ay≤100, 0≤bx,by≤10160≤bx,by≤1016), which define the coordinates of the data nodes.

The second line contains integers xsxs, ysys, tt (1≤xs,ys,t≤10161≤xs,ys,t≤1016) – the initial Aroma’s coordinates and the amount of time available.

Output
Print a single integer — the maximum number of data nodes Aroma can collect within tt seconds.

Examples
Input
1 1 2 3 1 0
2 4 20
Output
3
Input
1 1 2 3 1 0
15 27 26
Output
2
Input
1 1 2 3 1 0
2 2 1
Output
0
Note
In all three examples, the coordinates of the first 55 data nodes are (1,1)(1,1), (3,3)(3,3), (7,9)(7,9), (15,27)(15,27) and (31,81)(31,81) (remember that nodes are numbered from 00).

In the first example, the optimal route to collect 33 nodes is as follows:

Go to the coordinates (3,3)(3,3) and collect the 11-st node. This takes |3−2|+|3−4|=2|3−2|+|3−4|=2 seconds.
Go to the coordinates (1,1)(1,1) and collect the 00-th node. This takes |1−3|+|1−3|=4|1−3|+|1−3|=4 seconds.
Go to the coordinates (7,9)(7,9) and collect the 22-nd node. This takes |7−1|+|9−1|=14|7−1|+|9−1|=14 seconds.
In the second example, the optimal route to collect 22 nodes is as follows:

Collect the 33-rd node. This requires no seconds.
Go to the coordinates (7,9)(7,9) and collect the 22-th node. This takes |15−7|+|27−9|=26|15−7|+|27−9|=26 seconds.
In the third example, Aroma can’t collect any nodes. She should have taken proper rest instead of rushing into the OS space like that.
思路:通过观察可以发现,其实利益点与前一个利益点横纵坐标之间成幂次关系,这样的话就肯定不会太多,因此我们可以先暴力将所有范围内的点找出来然后暴力去找。在规定时间内能找到的利益点,肯定是连续的,因为不是连续点之间的距离一定大于连续点,贪心思想就一定是连续点。
代码如下:

#include<bits/stdc++.h>
#define ll long long
using namespace std;

const int maxx=300;
const ll inf=1e17;
ll xx[maxx],yy[maxx];
ll x0,yy0,ax,ay,bx,by;
ll xs,ys,t;

inline int init()
{
	int i=1;
	while(1)
	{
		xx[i]=ax*xx[i-1]+bx;
		yy[i]=ay*yy[i-1]+by;
		if(xx[i]>inf||yy[i]>inf) break;
		i++;
	}
	//for(int j=0;j<i;j++) cout<<xx[j]<<" "<<yy[j]<<endl;
	return i;
}
int main()
{
	scanf("%lld%lld%lld%lld%lld%lld",&x0,&yy0,&ax,&ay,&bx,&by);
	scanf("%lld%lld%lld",&xs,&ys,&t);
	xx[0]=x0,yy[0]=yy0;
	int n=init();
	int ans=0;
	//cout<<xs<<" "<<ys<<endl;
	//cout<<abs(xx[0]-xs)+abs(yy[0]-ys)<<endl;
	for(int i=0;i<n;i++)
	{
		for(int j=i;j<n;j++)
		{
			unsigned long long time=min(abs(xx[i]-xs)+abs(yy[i]-ys),abs(xx[j]-xs)+abs(yy[j]-ys));//在这里要用unsigned long long,因为会超出long long的范围。这一语句的意思是,选取距离最小的一个端点,这样才是最优。
			//cout<<time<<endl;
			time+=(abs(xx[j]-xx[i])+abs(yy[j]-yy[i]));
			if(time<=t) ans=max(ans,j-i+1);
			//cout<<time<<endl; 
		}
	}
	cout<<ans<<endl;
	return 0;
}

努力加油a啊,(o)/~

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

starlet_kiss

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值