{"problem":{"name":"C. Unfair Poll","description":{"content":"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 i","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF758C"},"statements":[{"statement_type":"Markdown","content":"On the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others.\n\nSeating in the class looks like a rectangle, where _n_ rows with _m_ pupils in each.\n\nThe 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, ...\n\nThe 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.\n\nDuring 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:\n\n1.  the maximum number of questions a particular pupil is asked,\n2.  the minimum number of questions a particular pupil is asked,\n3.  how many times the teacher asked Sergei.\n\nIf there is only one row in the class, then the teacher always asks children from this row.\n\n## Input\n\nThe 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_).\n\n## Output\n\nPrint three integers:\n\n1.  the maximum number of questions a particular pupil is asked,\n2.  the minimum number of questions a particular pupil is asked,\n3.  how many times the teacher asked Sergei.\n\n[samples]\n\n## Note\n\nThe order of asking pupils in the first test:\n\n1.  the pupil from the first row who seats at the first table, it means it is Sergei;\n2.  the pupil from the first row who seats at the second table;\n3.  the pupil from the first row who seats at the third table;\n4.  the pupil from the first row who seats at the first table, it means it is Sergei;\n5.  the pupil from the first row who seats at the second table;\n6.  the pupil from the first row who seats at the third table;\n7.  the pupil from the first row who seats at the first table, it means it is Sergei;\n8.  the pupil from the first row who seats at the second table;\n\nThe order of asking pupils in the second test:\n\n1.  the pupil from the first row who seats at the first table;\n2.  the pupil from the first row who seats at the second table;\n3.  the pupil from the second row who seats at the first table;\n4.  the pupil from the second row who seats at the second table;\n5.  the pupil from the third row who seats at the first table;\n6.  the pupil from the third row who seats at the second table;\n7.  the pupil from the fourth row who seats at the first table;\n8.  the pupil from the fourth row who seats at the second table, it means it is Sergei;\n9.  the pupil from the third row who seats at the first table;","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"在文学课上，谢尔盖发现了一个严重的不公现象：似乎有些学生被提问的次数比其他人更多。\n\n教室的座位呈矩形排列，共有 #cf_span[n] 行，每行有 #cf_span[m] 名学生。\n\n老师按以下顺序提问：首先，她按座位顺序提问第一行的所有学生，然后继续提问下一行的学生。如果老师提问到了最后一行，则提问方向反转，即开始提问前一行。提问行的顺序如下：第 #cf_span[1] 行、第 #cf_span[2] 行、#cf_span[...]、第 #cf_span[n - 1] 行、第 #cf_span[n] 行、第 #cf_span[n - 1] 行、#cf_span[...]、第 #cf_span[2] 行、第 #cf_span[1] 行、第 #cf_span[2] 行、#cf_span[...]。\n\n在同一行内，提问学生的顺序始终相同：第 #cf_span[1] 名学生、第 #cf_span[2] 名学生、#cf_span[...]、第 #cf_span[m] 名学生。\n\n在课堂上，老师总共按上述顺序提问了恰好 #cf_span[k] 次。谢尔盖坐在第 #cf_span[x] 行、该行的第 #cf_span[y] 个位置。谢尔盖决定向老师证明学生被提问的次数并不均匀，请帮他计算以下三个值：\n\n如果教室只有一行，则老师总是提问该行的学生。\n\n输入仅一行，包含五个整数 #cf_span[n], #cf_span[m], #cf_span[k], #cf_span[x] 和 #cf_span[y]（#cf_span[1 ≤ n, m ≤ 100, 1 ≤ k ≤ 1018, 1 ≤ x ≤ n, 1 ≤ y ≤ m]）。\n\n## Input\n\n输入仅一行，包含五个整数 #cf_span[n], #cf_span[m], #cf_span[k], #cf_span[x] 和 #cf_span[y]（#cf_span[1 ≤ n, m ≤ 100, 1 ≤ k ≤ 1018, 1 ≤ x ≤ n, 1 ≤ y ≤ m]）。\n\n## Output\n\n请输出三个整数：某个学生被提问的最大次数、某个学生被提问的最小次数、以及老师提问谢尔盖的次数。\n\n[samples]\n\n## Note\n\n第一个测试用例中提问学生的顺序：\n\n第一行第一座的学生，即谢尔盖；\n第一行第二座的学生；\n第一行第三座的学生；\n第一行第一座的学生，即谢尔盖；\n第一行第二座的学生；\n第一行第三座的学生；\n第一行第一座的学生，即谢尔盖；\n第一行第二座的学生。\n\n第二个测试用例中提问学生的顺序：\n\n第一行第一座的学生；\n第一行第二座的学生；\n第二行第一座的学生；\n第二行第二座的学生；\n第三行第一座的学生；\n第三行第二座的学生；\n第四行第一座的学生；\n第四行第二座的学生，即谢尔盖；\n第三行第一座的学生。","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n, m, k, x, y \\in \\mathbb{Z}^+ $ with $ 1 \\leq n, m \\leq 100 $, $ 1 \\leq k \\leq 10^{18} $, $ 1 \\leq x \\leq n $, $ 1 \\leq y \\leq m $.  \nLet the seating be an $ n \\times m $ grid. The teacher asks in a back-and-forth row order:  \n$ 1 \\to 2 \\to \\cdots \\to n \\to n-1 \\to \\cdots \\to 2 \\to 1 \\to 2 \\to \\cdots $ (periodic with period $ 2(n-1) $ for rows, excluding the first and last row being visited once per cycle).  \nWithin each row, pupils are asked left to right: position $ 1 $ to $ m $.\n\n**Constraints**  \n1. $ 1 \\leq n, m \\leq 100 $  \n2. $ 1 \\leq k \\leq 10^{18} $  \n3. $ 1 \\leq x \\leq n $, $ 1 \\leq y \\leq m $\n\n**Objective**  \nCompute three values:  \n1. The total number of times pupil at $ (x, y) $ is asked in the first $ k $ questions.  \n2. The total number of questions asked to the entire row $ x $ in the first $ k $ questions.  \n3. The position (1-indexed) in the sequence of questions at which the pupil $ (x, y) $ is asked for the **first** time (if never asked within $ k $, output 0).\n\n**Note**: If $ n = 1 $, the row cycle is trivial: always row 1.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF758C","tags":["binary search","constructive algorithms","implementation","math"],"sample_group":[["1 3 8 1 1","3 2 3"],["4 2 9 4 2","2 1 1"],["5 5 25 4 3","1 1 1"],["100 100 1000000000000000000 100 100","101010101010101 50505050505051 50505050505051"]],"created_at":"2026-03-03 11:00:39"}}