Unfair Poll
来源:互联网 发布:方正电子书数据库 编辑:程序博客网 时间:2024/06/08 08:07
题目不难,请注意细节
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 mpupils 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:
- 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 integers n, m, k, x and y(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>int main(){int n,m,x,y;long long k,an[105][105]={0},_max=-1,_min=1e18+5;scanf("%d%d%lld%d%d",&n,&m,&k,&x,&y);int all,left;long long base;if(n==1){base=k/m;left=k%m;}else{all=n*m+(n-2)*m;base=k/all;left=k%all;}if(left==0){_min=base;}for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){if(i==1||i==n)an[i][j]=base;elsean[i][j]=2*base;if(an[i][j]>_max)_max=an[i][j];}}for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){if(left!=0){an[i][j]++;left--;if(an[i][j]>_max)_max=an[i][j];if(an[i][j]<_min)_min=an[i][j];}if(left==0)break;}if(left==0)break;}for(int i=n-1;i>1;i--){for(int j=1;j<=m;j++){if(left!=0){an[i][j]++;left--;if(an[i][j]>_max)_max=an[i][j];if(an[i][j]<_min)_min=an[i][j];}if(left==0)break;}if(left==0)break;}for(int j=1;j<=m;j++){if(an[1][j]>_max)_max=an[1][j];if(an[1][j]<_min)_min=an[1][j];}for(int j=1;j<=m;j++){if(an[n][j]>_max)_max=an[n][j];if(an[n][j]<_min)_min=an[n][j];}printf("%lld %lld %lld",_max,_min,an[x][y]);return 0;}
- Unfair Poll
- Unfair Poll
- Codeforces758C Unfair Poll
- 758C - Unfair Poll
- Unfair Poll CodeForces
- Unfair Poll codeforce758 C
- 【codeforces 758C】Unfair Poll
- codeforces 392 div2 unfair poll
- Codeforces 758C-Unfair Poll
- Codeforces 758C Unfair Poll
- Codeforces 758C- 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 Round #392 (Div. 2)Unfair Poll
- [java]二叉树构建、遍历、深度、平衡性
- POJ 1743 Musical Theme (后缀树组)
- 关于LINUX系统下部署javaweb项目失败报错404的问题
- Windows桌面共享中一些常见的抓屏技术
- java里的print与println
- Unfair Poll
- Windows Spring源码编译
- python+selenium自动化软件测试(第5章):Selenium Gird
- 《HBase权威指南》读书笔记 第八章:架构,存储
- python 装饰器
- 斯坦福Nature论文宣布新突破:深度学习皮肤癌诊断达专家水平
- [NOIP2017模拟]举办比赛
- java进制转换
- java中的static关键字