Unfair Poll codeforce758 C
来源:互联网 发布:淘宝凤凰体育 编辑:程序博客网 时间:2024/05/21 03:27
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, wheren rows withm 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: the1-st row, the2-nd row,..., then - 1-st row, then-th row, then - 1-st row,..., the2-nd row, the1-st row, the2-nd row,...
The order of asking of pupils on the same row is always the same: the1-st pupil, the2-nd pupil,..., them-th pupil.
During the lesson the teacher managed to ask exactlyk questions from pupils in order described above. Sergei seats on thex-th row, on they-th place in the row. Sergei decided to prove to the teacher that pupils are asked irregularly, help him count three values:
- the maximum number of questions a particular pupil is asked,
- the minimum number of questions a particular pupil is asked,
- 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 integersn,m,k,x andy (1 ≤ n, m ≤ 100, 1 ≤ k ≤ 1018, 1 ≤ x ≤ n, 1 ≤ y ≤ m).
Print three integers:
- the maximum number of questions a particular pupil is asked,
- the minimum number of questions a particular pupil is asked,
- how many times the teacher asked Sergei.
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
The order of asking pupils in the first test:
- the pupil from the first row who seats at the first table, it means it is Sergei;
- the pupil from the first row who seats at the second table;
- the pupil from the first row who seats at the third table;
- the pupil from the first row who seats at the first table, it means it is Sergei;
- the pupil from the first row who seats at the second table;
- the pupil from the first row who seats at the third table;
- the pupil from the first row who seats at the first table, it means it is Sergei;
- the pupil from the first row who seats at the second table;
The order of asking pupils in the second test:
- the pupil from the first row who seats at the first table;
- the pupil from the first row who seats at the second table;
- the pupil from the second row who seats at the first table;
- the pupil from the second row who seats at the second table;
- the pupil from the third row who seats at the first table;
- the pupil from the third row who seats at the second table;
- the pupil from the fourth row who seats at the first table;
- the pupil from the fourth row who seats at the second table, it means it is Sergei;
- the pupil from the third row who seats at the first table;
#include<stdio.h>#include<algorithm>#include<string.h>#include<string>#include<iostream>#include<math.h>using namespace std;#define LL long longLL n, m, k, x, y;int main(){ cin>>n>>m>>k>>x>>y; LL p, r, masum, misum, ans; if(n == 1) { p = k/m; r = k%m; masum = k/m + (r > 0); misum = k/m; ans = p + (r >= y); } else { if(k <= m*n) { masum = 1; misum = (k == m*n ? 1 : 0); ans = ((x-1)*m + y <= k); } else { p = k/(m*n+(n-2)*m); r = k % (m*n+(n-2)*m); if(n == 2) masum = p + (r >= 1); else masum = 2*p + (r > m) + (r > m*n); misum = p + (r >= m*n); if(x == 1 || x == n) ans = p + (r >= (x-1)*m + y); else ans = 2*p + (r >= (x-1)*m + y) + (r >= n*m+(n-x-1)*m + y); } } cout<<masum<<" "<<misum<<" "<<ans<<endl; return 0;}
- Unfair Poll codeforce758 C
- 758C - Unfair Poll
- 【codeforces 758C】Unfair Poll
- Codeforces 758C-Unfair Poll
- Codeforces 758C Unfair Poll
- Codeforces 758C- Unfair Poll
- Unfair Poll
- Unfair Poll
- Codeforces 758C Unfair Poll 暴力模拟
- codeforces 758C - Unfair Poll 细节题
- Codeforces 758C Unfair Poll 【数学】【思维】
- CF758 C. Unfair Poll (模拟)
- 【Codeforces 758 C Unfair Poll】+ 细节
- C. Unfair Poll-数数你会不会?
- CodeForces 758C Unfair Poll(模拟)
- Codeforces Round #392 (Div. 2) C - Unfair Poll codeforces
- Codeforces Round #392 (Div. 2) C. Unfair Poll
- Codeforces Round #392 (Div. 2)-C. Unfair Poll(xjb)
- Revive开发商加入VR开源标准OpenXR
- 教您用公式编辑器快速输入公式
- 本地PostgreSQL数据库远程访问
- 第三周:240. Search a 2D Matrix II(搜索二维矩阵之二)
- jeeplus-js-获取table中复选框选中的列
- Unfair Poll codeforce758 C
- 跨页面通信的各种姿势
- 批量修改同一张表
- ActiveMQ(二)-Spring集成JMS
- 题目76:超级台阶
- linux的poll机制
- linux系统监控工具
- jquery滚动页面底部时函数加载多次解决办法
- 洛谷 P1069 细胞分裂 质因数分解