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:

  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.

Input

The first and the only line contains five integers nmkx and y (1 ≤ n, m ≤ 100, 1 ≤ k ≤ 1018, 1 ≤ x ≤ n, 1 ≤ y ≤ m).

Output

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.
Examples
input
output
input
output
input
output
input
output
Note

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;

题意:n行m列的学生,老师从头开始点名第一排和最后一排每个周期只点一次。周期如图

题解:n==1 和 n==2单独处理,其他情况先算出有多少个周期,再讨论剩下部分能给三个答案加多少,特别注意一个周期都没有的情况。

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
long long n,m;
long long k;
long long x,y;
long long maxx,minn,ans;
long long T,t;
long long res = ;
long long time = ; void solve()
{
T=*m*n - *m;
t=n*m;
time = k/T;
res = k%T;
if(res == )
maxx = time*;
if(res <= m)
maxx = max(time*,time+);
else if(res <= t)
maxx = time*+;
else if(res < T)
maxx = time*+; if(res < t )
minn = time;
else
minn = time+; if(x == || x == n)
ans+=time;
else
ans+=time*; long long cnt = ;
for(long long i=;i<=n;i++){
for(long long j=;j<=m;j++){
cnt++;
if(cnt > res)
break;
if(x == i && y == j)
ans++;
}
}
for(long long i=n-;i>=;i--){
for(long long j=;j<=m;j++){
cnt++;
if(cnt > res)
break;
if(x == i && y == j)
ans++;
}
}
} int main()
{
cin>>n>>m>>k>>x>>y; if( n== ){
T=m;
res = k%T;
time = k/T;
maxx = ((res==)?(time):(time+));
minn = time;
ans = ((res>=y)?(time+):time);
}
else if(n == ){
T=n*m;
res = k%T;
time = k/T;
maxx = ((res==)?(time):(time+));
minn = time;
ans = ((res>=(x-)*y+y)?(time+):time);
}
else{
solve();
} cout<<maxx<<" "<<minn<<" "<<ans<<endl; return ;
}

Codeforces 758C-Unfair Poll的更多相关文章

  1. CodeFroces 758C - Unfair Poll

    题意: 老师点名,顺序是1 -- n -- 1 排为一个循环,每列为1 -- m的顺序, 问点到最多次数和最少次数的人的次数以及(x,y)被点的次数. 分析: 由于点名有循环,故可先判断出每一个循环每 ...

  2. 【找规律】Codeforces Round #392 (Div. 2) C. Unfair Poll

    C. Unfair Poll time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  3. Codeforces Round #392 (Div. 2) Unfair Poll

    C. Unfair Poll time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  4. CodeForces 758 C Unfair Poll

    Unfair Poll 题意:一共有n排同学每排同学有m个人, 老师问问题有一个顺序, 先从第一排开始问,问完第一排的所有同学之后,再问第2排的,对于所有排的访问顺序为 1,2,3……n-1,n,n- ...

  5. C. Unfair Poll

    http://codeforces.com/problemset/problem/758/C C. Unfair Poll time limit per test 1 second memory li ...

  6. Codeforces758C Unfair Poll 2017-01-20 10:24 95人阅读 评论(0) 收藏

    C. Unfair Poll time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  7. 【codeforces 758C】Unfair Poll

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. Codeforces 758C:Unfair Poll(思维+模拟)

    http://codeforces.com/problemset/problem/758/C 题意:教室里有n列m排,老师上课点名从第一列第一排开始往后点,直到点到第一列第m排,就从第二列第一排开始点 ...

  9. Codeforces 392 C Unfair Poll(模拟)

    题意:老师点名顺序规则如下:第1排,第2排,……,第n-1排,第n排,第n-1排,……,第2排,第1排,第2排,……,第n-1排,第n排,……对于每排都是从左到右依次点名,问点名k个人后,所有人中最多 ...

  10. CF758C Unfair Poll

    题意: On the Literature lesson Sergei noticed an awful injustice, it seems that some students are aske ...

随机推荐

  1. KVM虚拟化管理 virt manager常用操作

    部分涉及到Linux.Nginx.tomcat.MySQL等的点滴操作记录,时间长了,就忘掉了,偶尔整理一下操作的history,就此简要备份一下: [原][BG]-一次虚拟化环境实践简要记录: ht ...

  2. hive行转列

    一.问题 hive如何将 a ,, b , c 转化成为: a a a b b c 二.原始数据 cat row_column.txt a ,, b , c 三.解决方案 3.1 遍历每一列 3.1. ...

  3. libmongoc关于\$pullAll和\$addToSet的一个使用问题记录

    问题描述及测试结果 在使用mongodb时,对一个document中的数组成员进行更新的时候,可以使用$pull $push $pop $addToSet $pullAll和$each $positi ...

  4. ios入门篇 -hello Word(1)

    温馨提示:,如果您使用移动终端阅读本篇文章,请连接wifi的情况下阅读,里面有大量图片,以免造成您不必要的损失.   潜水博客园很多年,闲来无事,聊一下自己的经历,语文不好(如有什么错别字,请您在下评 ...

  5. WCF中记录SOAP消息日志

    Windows Communication Foundation (WCF) 默认启用消息日志,WCF使用了在System.Diagnostics名称空间中定义的跟踪机制.在这个跟踪机制中,通过在配置 ...

  6. 安卓打印实现打印pdf文档

    先声明一下,此处的打印非pos打印机打印和蓝牙打印机打印,如果想查找打印小票的pos打印机请进入下面的传送门,蓝牙打印目前没做过,有做过的请指教. pos打印机传送门: 1. https://www. ...

  7. JEECG中表单提交的中断

    JEECG平台中基于form表单封装了<t:formvalid>标签,对应实现的类为FormValidationTag.java文件. 很多时候在正式向后台提交数据前想要做判断处理,若通过 ...

  8. 第三部分:Android 应用程序接口指南---第二节:UI---第十章 拖放

    第10章 拖放 使用Android的拖放框架,允许用户通过一个图形化的拖放动作,把数据从当前布局中的一个视图上转移到另一个视图上.这个框架包含了一个拖动事件类,拖动监听器和一些辅助的方法和类. 虽然这 ...

  9. [svc]openssl对称非对称加密实战

    OpenSSL进行aes加密解密-对称加密(symmetry) 建立文件test.txt, 特意写入中英文 # cd /tmp # echo "test测试" > test. ...

  10. 01——Introduction to Android介绍

    Introduction to Android Android provides a rich application framework that allows you to build innov ...