CF385E.Bear in the Field
提高+/省选-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Our bear's forest has a checkered field. The checkered field is an n × n table, the rows are numbered from 1 to n from top to bottom, the columns are numbered from 1 to n from left to right. Let's denote a cell of the field on the intersection of row x and column y by record (x, y). Each cell of the field contains growing raspberry, at that, the cell (x, y) of the field contains x + y raspberry bushes.
The bear came out to walk across the field. At the beginning of the walk his speed is (dx, dy). Then the bear spends exactly t seconds on the field. Each second the following takes place:
- Let's suppose that at the current moment the bear is in cell (x, y).
- First the bear eats the raspberry from all the bushes he has in the current cell. After the bear eats the raspberry from k bushes, he increases each component of his speed by k. In other words, if before eating the k bushes of raspberry his speed was (dx, dy), then after eating the berry his speed equals (dx + k, dy + k).
- Let's denote the current speed of the bear (dx, dy) (it was increased after the previous step). Then the bear moves from cell (x, y) to cell (((x + dx - 1) mod n) + 1, ((y + dy - 1) mod n) + 1).
- Then one additional raspberry bush grows in each cell of the field.
You task is to predict the bear's actions. Find the cell he ends up in if he starts from cell (sx, sy). Assume that each bush has infinitely much raspberry and the bear will never eat all of it.
我们的小熊的森林里有一片方格状的场地。该方格场地是一个 n×n 的表格,行号从上到下依次为 1 到 n,列号从左到右依次为 1 到 n。我们用 (x,y) 表示位于第 x 行、第 y 列的格子。场地中每个格子都生长着覆盆子灌木,其中格子 (x,y) 中恰好有 x+y 株覆盆子灌木。
小熊出发在场地上散步。初始时刻,它的速度为 (dx,dy)。随后,小熊恰好在场地上停留 t 秒。每一秒内,将发生如下过程:
- 假设当前时刻小熊位于格子 (x,y)。
- 首先,小熊吃掉当前格子中所有灌木上的覆盆子。当它吃掉 k 株灌木上的覆盆子后,其速度的两个分量均增加 k。换言之,若吃覆盆子前速度为 (dx,dy),则吃完后速度变为 (dx+k,dy+k)。
- 记此时小熊的速度为 (dx,dy)(已在上一步中更新)。接着,小熊从格子 (x,y) 移动到格子 (((x+dx−1)modn)+1,((y+dy−1)modn)+1)。
- 然后,场地上每个格子中额外长出一株覆盆子灌木。
你的任务是预测小熊的行动:给定起始格子 (sx,sy),请计算 t 秒后小熊最终所在的格子。假设每株灌木上覆盆子数量无限,小熊永远不会将其吃光。
输入格式
The first line of the input contains six space-separated integers: n, sx, sy, dx, dy, t (1 ≤ n ≤ 109; 1 ≤ sx, sy ≤ n; - 100 ≤ dx, dy ≤ 100; 0 ≤ t ≤ 1018).
输入的第一行包含六个用空格分隔的整数:n、sx、sy、dx、dy、t(其中 1 ≤ n ≤ 109;1 ≤ sx, sy ≤ n;−100 ≤ dx, dy ≤ 100;0 ≤ t ≤ 1018)。
输出格式
Print two integers — the coordinates of the cell the bear will end up in after t seconds.
输出两个整数——熊在 t 秒后所处格子的坐标。
输入输出样例
输入#1
5 1 2 0 1 2
输出#1
3 1
输入#2
1 1 1 -1 -1 2
输出#2
1 1
说明/提示
Operation a mod b means taking the remainder after dividing a by b. Note that the result of the operation is always non-negative. For example, ( - 1) mod 3 = 2.
In the first sample before the first move the speed vector will equal (3,4) and the bear will get to cell (4,1). Before the second move the speed vector will equal (9,10) and he bear will get to cell (3,1). Don't forget that at the second move, the number of berry bushes increased by 1.
In the second sample before the first move the speed vector will equal (1,1) and the bear will get to cell (1,1). Before the second move, the speed vector will equal (4,4) and the bear will get to cell (1,1). Don't forget that at the second move, the number of berry bushes increased by 1.
运算 amodb 表示 a 除以 b 后所得的余数。注意,该运算的结果恒为非负数。例如,(−1)mod3=2。
在第一个样例中,第一次移动前,速度向量为 (3,4),熊将到达格子 (4,1);第二次移动前,速度向量为 (9,10),熊将到达格子 (3,1)。请注意:在第二次移动时,浆果丛的数量增加了 1。
在第二个样例中,第一次移动前,速度向量为 (1,1),熊将到达格子 (1,1);第二次移动前,速度向量为 (4,4),熊将再次到达格子 (1,1)。请注意:在第二次移动时,浆果丛的数量增加了 1。
输入解题思路,AI测评打分。不知道怎么写?