日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Aroma's Search(暴力)

發布時間:2023/12/15 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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)/~

總結

以上是生活随笔為你收集整理的Aroma's Search(暴力)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。