博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【找规律】Codeforces Round #392 (Div. 2) C. Unfair Poll
阅读量:5948 次
发布时间:2019-06-19

本文共 3799 字,大约阅读时间需要 12 分钟。

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:

  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
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:

  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;

 

假设老师从第一行叫到最后一行或者从最后一行叫到第一行是一轮,可以得到式子m(nq-q+1)<=k,由此可以推出q(轮数)的最大值。

剩余的叫的次数就可以暴力了。

#include
#include
using namespace std;typedef long long ll;ll K;int n,m,x,y;ll ci[110];int a[110][110];int main(){// freopen("c.in","r",stdin); scanf("%d%d%I64d%d%d",&n,&m,&K,&x,&y); if(n==1) { if(K%(ll)m==0) printf("%I64d %I64d %I64d\n",K/(ll)m,K/(ll)m,K/(ll)m); else printf("%I64d %I64d %I64d\n",K/(ll)m+1ll,K/(ll)m,(ll)y<=K%(ll)m ? K/(ll)m+1ll : K/(ll)m); return 0; } ll q=(K-(ll)m)/(ll)(m*(n-1)); ll _n=q/2ll; ll _1=(q-1)/2ll; for(int i=2;i

转载于:https://www.cnblogs.com/autsky-jadek/p/6321752.html

你可能感兴趣的文章
SSH隧道与端口转发及内网穿透
查看>>
我的友情链接
查看>>
nginx配置文件之---location
查看>>
网站上的常驻条
查看>>
mysql多实例实例化数据库
查看>>
Sql 字符串长度不足补0
查看>>
我的友情链接
查看>>
golang xml和json的解析与生成
查看>>
小弟的新书《Ext JS权威指南》终于出版了
查看>>
类图的总结与学习 OOA
查看>>
好吧好吧,就在这里消磨时间
查看>>
二层的,DTP+CAM/ARP
查看>>
2011工作总结
查看>>
Java学习笔记二:Java开发工具Eclipse的安装与使用
查看>>
3.4-ansible远程执行脚本
查看>>
常见邮件服务器(接收服务器和发送邮件服务器)地址
查看>>
系统监控Zabbix部署文档
查看>>
我的友情链接
查看>>
计算机网络练习题(一)
查看>>
Web服务器技术的优缺点
查看>>