A10671 | Unfair Poll
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The first and the only line contains five integers $n$ , $m$ , $k$ , $x$ and $y$ ( $1<=n,m<=100,1<=k<=10^{18},1<=x<=n,1<=y<=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. 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
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. 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;
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted