Codeforces Round #392 (Div. 2) C. Unfair Poll
2017-01-20 13:04
162 查看
C. Unfair Poll
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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:
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.
Input
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).
Output
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.
Examples
input
output
input
output
input
output
input
output
Note
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;
题目大意:
给出n个学生 从 1 -n -1 这样点名,(一般来说然第一排和最后一排点到的次数会少
每排 m 个学生,现在点名 k 个学生,按照上述顺序,给出一个特别的学生 位置
问被点名最多的学生的点名次数,最少的,还有特别学生被点名了多少次。
思路:
大模拟,mdzz 一开始居然去找规律了,既然存在周期,那么就先减去周期,然后直接模拟剩下的就可以了。
居然卡我一个小时没写出来。。。
zz了。
AC代码:
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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:
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.
Input
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).
Output
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.
Examples
input
1 3 8 1 1
output
3 2 3
input
4 2 9 4 2
output
2 1 1
input
5 5 25 4 3
output
1 1 1
input
100 100 1000000000000000000 100 100
output
101010101010101 50505050505051 50505050505051
Note
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;
题目大意:
给出n个学生 从 1 -n -1 这样点名,(一般来说然第一排和最后一排点到的次数会少
每排 m 个学生,现在点名 k 个学生,按照上述顺序,给出一个特别的学生 位置
问被点名最多的学生的点名次数,最少的,还有特别学生被点名了多少次。
思路:
大模拟,mdzz 一开始居然去找规律了,既然存在周期,那么就先减去周期,然后直接模拟剩下的就可以了。
居然卡我一个小时没写出来。。。
zz了。
AC代码:
#include<bits/stdc++.h> using namespace std; int fx,fy;long long int n,m,k,x,y;\ long long int zz,ff; int haha(long long int t) { int work=1; int dd=1; int ans=0; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { if(t==0) { return ans; } if(i>1) { if(work) { work=0; zz++; } } t--; if(i==x&&j==y) { ans++; } } } int kkk=1; ff++; for(int i=n-1;i>1;i--) { for(int j=1;j<=m;j++) { if(t==0) { return ans; } if(kkk) { kkk=0; zz++; } t--; if(i==x&&y==j) { ans++; } } } } int main() { scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&k,&x,&y); if(n==1||n==2) { y=(x-1)*m+y; m=n*m; if(k%m==0) { cout<<k/m<<" "<<k/m<<" "<<k/m<<endl; } else { cout<<k/m+1<<" "<<k/m<<" "; if(y>k%m) { cout<<k/m<<endl; } else { cout<<k/m+1<<endl; } } } else { long long int num; num=m*((n-2)*2+2); long long int t=k%num; long long int aa=k/num; zz=2*aa; ff=aa; int hh=haha(t); if(zz==0&&ff==0) { zz=1; } if(zz<ff) { cout<<ff<<" "<<zz<<" "; } else { cout<<zz<<" "<<ff<<" "; } if(x==1||x==n) { cout<<aa+hh<<endl; } else { cout<<2*aa+hh<<endl; } } }
相关文章推荐
- 浮动固定Div(转载)
- 目前流行的CSS+DIV的命名规则
- Codeforces Round #219(Div. 2)373 B. Making Sequences is Fun(二分+找规律)
- Codeforces Round #272 (Div. 2) B. Dreamoon and WiFi 暴力
- Codeforces Beta Round #96 (Div. 1) C. Logo Turtle (DP)
- event 事件 clientX 和clientY 配合scrollTop使用, div跟着鼠标走
- css效果,在一个盒子里,把一部分内容隐藏掉,在鼠标悬停到div时,就会把隐藏的部分向上显示出来。 不用js操作,纯css就可以。
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) A B C D 暴力 水 二分 几何
- Codeforces Round #443 (Div. 1) C. Tournament
- 覆盖整个页面的div
- 【IE6.0 Bug总结之三】div无法遮盖select问题
- div+css模拟京东导航
- Codeforces Round #272 (Div. 2) B
- Codeforces Round #310 (Div. 1) B. Case of Fugitive 贪心
- Codeforces Round #345 (Div. 2) B. Beautiful Paintings
- codeforce contest 713 #371 Div1 A
- Codeforces Round #392 (Div. 2)
- Codeforces Round #392 (Div. 2) 题解
- 关于div设置最小高度,超过后自动增加的css,兼容IE和火狐
- div布局的问题