codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1292B.md (3205B)


      1 Source: https://codeforces.com/problemset/problem/1292/B
      2 
      3 B. Aroma's Search
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 [THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu)
     22 
     23 [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives)
     24 
     25 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.
     26 
     27 The space can be considered a 2D plane, with an infinite number of data nodes, indexed from $0$, with their coordinates defined as follows:
     28 
     29 * The coordinates of the $0$-th node is $(x_0, y_0)$
     30 * For $i \gt 0$, the coordinates of $i$-th node is $(a_x \cdot x_{i-1} + b_x, a_y \cdot y_{i-1} + b_y)$
     31 
     32 Initially Aroma stands at the point $(x_s, y_s)$. She can stay in OS space for at most $t$ seconds, because after this time she has to warp back to the real world. She doesn't need to return to the entry point $(x_s, y_s)$ to warp home.
     33 
     34 While within the OS space, Aroma can do the following actions:
     35 
     36 * From the point $(x, y)$, Aroma can move to one of the following points: $(x-1, y)$, $(x+1, y)$, $(x, y-1)$ or $(x, y+1)$. This action requires $1$ second.
     37 * If there is a data node at where Aroma is staying, she can collect it. We can assume this action costs $0$ seconds. Of course, each data node can be collected at most once.
     38 
     39 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 $t$ seconds?
     40 
     41 Input
     42 
     43 The first line contains integers $x_0$, $y_0$, $a_x$, $a_y$, $b_x$, $b_y$ ($1 \leq x_0, y_0 \leq 10^{16}$, $2 \leq a_x, a_y \leq 100$, $0 \leq b_x, b_y \leq 10^{16}$), which define the coordinates of the data nodes.
     44 
     45 The second line contains integers $x_s$, $y_s$, $t$ ($1 \leq x_s, y_s, t \leq 10^{16}$) – the initial Aroma's coordinates and the amount of time available.
     46 
     47 Output
     48 
     49 Print a single integer — the maximum number of data nodes Aroma can collect within $t$ seconds.
     50 
     51 Examples
     52 
     53 Input
     54 
     55 ```
     56 1 1 2 3 1 0
     57 2 4 20
     58 ```
     59 
     60 Output
     61 
     62 ```
     63 3
     64 ```
     65 
     66 Input
     67 
     68 ```
     69 1 1 2 3 1 0
     70 15 27 26
     71 ```
     72 
     73 Output
     74 
     75 ```
     76 2
     77 ```
     78 
     79 Input
     80 
     81 ```
     82 1 1 2 3 1 0
     83 2 2 1
     84 ```
     85 
     86 Output
     87 
     88 ```
     89 0
     90 ```
     91 
     92 Note
     93 
     94 In all three examples, the coordinates of the first $5$ data nodes are $(1, 1)$, $(3, 3)$, $(7, 9)$, $(15, 27)$ and $(31, 81)$ (remember that nodes are numbered from $0$).
     95 
     96 In the first example, the optimal route to collect $3$ nodes is as follows:
     97 
     98 * Go to the coordinates $(3, 3)$ and collect the $1$-st node. This takes $|3 - 2| + |3 - 4| = 2$ seconds.
     99 * Go to the coordinates $(1, 1)$ and collect the $0$-th node. This takes $|1 - 3| + |1 - 3| = 4$ seconds.
    100 * Go to the coordinates $(7, 9)$ and collect the $2$-nd node. This takes $|7 - 1| + |9 - 1| = 14$ seconds.
    101 
    102 In the second example, the optimal route to collect $2$ nodes is as follows:
    103 
    104 * Collect the $3$-rd node. This requires no seconds.
    105 * Go to the coordinates $(7, 9)$ and collect the $2$-th node. This takes $|15 - 7| + |27 - 9| = 26$ seconds.
    106 
    107 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.