CF758C.Unfair Poll

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

On the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others.

Seating in the class looks like a rectangle, where n rows with m pupils in each.

The teacher asks pupils in the following order: at first, she asks all pupils from the first row in the order of their seating, then she continues to ask pupils from the next row. If the teacher asked the last row, then the direction of the poll changes, it means that she asks the previous row. The order of asking the rows looks as follows: the 1-st row, the 2-nd row, ..., the n - 1-st row, the n-th row, the n - 1-st row, ..., the 2-nd row, the 1-st row, the 2-nd row, ...

The order of asking of pupils on the same row is always the same: the 1-st pupil, the 2-nd pupil, ..., the m-th pupil.

During the lesson the teacher managed to ask exactly k questions from pupils in order described above. Sergei seats on the x-th row, on the y-th place in the row. Sergei decided to prove to the teacher that pupils are asked irregularly, help him count three values:

  1. the maximum number of questions a particular pupil is asked,
  2. the minimum number of questions a particular pupil is asked,
  3. how many times the teacher asked Sergei.

If there is only one row in the class, then the teacher always asks children from this row.

在语文课上,谢尔盖注意到了一个严重的不公现象:似乎有些学生被提问的次数比其他学生更多。

教室里的座位呈矩形排列,共有 nn 行,每行有 mm 名学生。

教师按如下顺序提问学生:首先,她按座位顺序依次提问第一行的所有学生;接着继续提问下一行的学生。当教师提问完最后一行后,提问方向发生反转,即开始提问上一行的学生。因此,各行被提问的顺序为:第 11 行、第 22 行、……、第 n−1n-1 行、第 nn 行、第 n−1n-1 行、……、第 22 行、第 11 行、第 22 行、……

在同一行内,学生的提问顺序始终不变:第 11 位学生、第 22 位学生、……、第 mm 位学生。

在本节课中,教师恰好按上述顺序向学生提出了 kk 个问题。谢尔盖坐在第 xx 行、该行的第 yy 个位置。谢尔盖决定向老师证明学生被提问的频率并不均匀,请你帮助他计算以下三个值:

  1. 某位学生被提问次数的最大值,
  2. 某位学生被提问次数的最小值,
  3. 谢尔盖本人被提问的次数。

如果教室中只有一行学生,则教师始终只向该行的学生提问。

输入格式

The first and the only line contains five integers n, m, k, x and y (1 ≤ n, m ≤ 100, 1 ≤ k ≤ 1018, 1 ≤ x ≤ n, 1 ≤ y ≤ m).

第一行且唯一一行包含五个整数 nn、mm、kk、xx 和 yy(满足 1 ≤ n, m ≤ 1001 \leq n, m \leq 100,1 ≤ k ≤ 10181 \leq k \leq 10^{18},1 ≤ x ≤ n1 \leq x \leq n,1 ≤ y ≤ m1 \leq y \leq m)。

输出格式

Print three integers:

  1. the maximum number of questions a particular pupil is asked,
  2. the minimum number of questions a particular pupil is asked,
  3. how many times the teacher asked Sergei.

输出三个整数:

  1. 某位学生被提问的最大次数,
  2. 某位学生被提问的最小次数,
  3. 老师提问谢尔盖的次数。

输入输出样例

  • 输入#1

    1 3 8 1 1

    输出#1

    3 2 3
  • 输入#2

    4 2 9 4 2

    输出#2

    2 1 1
  • 输入#3

    5 5 25 4 3

    输出#3

    1 1 1
  • 输入#4

    100 100 1000000000000000000 100 100

    输出#4

    101010101010101 50505050505051 50505050505051

说明/提示

The order of asking pupils in the first test:

  1. the pupil from the first row who seats at the first table, it means it is Sergei;
  2. the pupil from the first row who seats at the second table;
  3. the pupil from the first row who seats at the third table;
  4. the pupil from the first row who seats at the first table, it means it is Sergei;
  5. the pupil from the first row who seats at the second table;
  6. the pupil from the first row who seats at the third table;
  7. the pupil from the first row who seats at the first table, it means it is Sergei;
  8. the pupil from the first row who seats at the second table;

The order of asking pupils in the second test:

  1. the pupil from the first row who seats at the first table;
  2. the pupil from the first row who seats at the second table;
  3. the pupil from the second row who seats at the first table;
  4. the pupil from the second row who seats at the second table;
  5. the pupil from the third row who seats at the first table;
  6. the pupil from the third row who seats at the second table;
  7. the pupil from the fourth row who seats at the first table;
  8. the pupil from the fourth row who seats at the second table, it means it is Sergei;
  9. the pupil from the third row who seats at the first table;

第一次测验中提问学生的顺序:

  1. 第一排坐在第一张桌子的学生,即谢尔盖;
  2. 第一排坐在第二张桌子的学生;
  3. 第一排坐在第三张桌子的学生;
  4. 第一排坐在第一张桌子的学生,即谢尔盖;
  5. 第一排坐在第二张桌子的学生;
  6. 第一排坐在第三张桌子的学生;
  7. 第一排坐在第一张桌子的学生,即谢尔盖;
  8. 第一排坐在第二张桌子的学生;

第二次测验中提问学生的顺序:

  1. 第一排坐在第一张桌子的学生;
  2. 第一排坐在第二张桌子的学生;
  3. 第二排坐在第一张桌子的学生;
  4. 第二排坐在第二张桌子的学生;
  5. 第三排坐在第一张桌子的学生;
  6. 第三排坐在第二张桌子的学生;
  7. 第四排坐在第一张桌子的学生;
  8. 第四排坐在第二张桌子的学生,即谢尔盖;
  9. 第三排坐在第一张桌子的学生;

输入解题思路,AI测评打分。不知道怎么写?

首页