CodeFroces 758C - Unfair Poll
题意:
老师点名,顺序是1 -- n -- 1 排为一个循环,每列为1 -- m的顺序, 问点到最多次数和最少次数的人的次数以及(x,y)被点的次数。
分析:
由于点名有循环,故可先判断出每一个循环每个人被点名的次数,再乘以循环数,为答案一部分。
最后一个循环结束后k还有余数,从(1,1)暴力模拟,因为n*m才10000, 再加上前面的,就能得出答案。
注意 n=1 需要特判。
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int mp[][];
int n, m, x, y;
LL c, k;
LL res1, res2, res3;
int main()
{
scanf("%d%d%I64d%d%d", &n, &m, &k, &x, &y);
if (n == )
{
LL a = k/m;
k %= m;
if (k == ) res1 = res2 = res3 = a;
else
{
res1 = a+;
res2 = a;
res3 = a;
if (y <= k) res3++;
}
}
else
{
memset(mp, , sizeof(mp));
c = k / ((*n-) * m);
k %= (*n-)*m;
int r = ;
while (k > )
{
if (r == )
{
for (r; r < n && k; r++)
{
for (int j = ; j <= m && k; j++)
{
++mp[r][j];
k--;
}
}
}
else if (r == n)
{
for (r; r > && k; r--)
{
for (int j = ; j <= m && k; j++)
{
++mp[r][j];
k--;
}
}
}
}
res1 = , res2 = mp[][] + c;
for (int i = ; i <= n; i++)
for (int j = ; j <= m; j++)
{
if (i == || i == n)
res1 = max(res1, mp[i][j] + c), res2 = min(res2, mp[i][j] + c);
else
res1 = max(res1, mp[i][j] + *c), res2 = min(res2, mp[i][j] + *c);
}
if (x == || x == n)
res3 = c + mp[x][y];
else
res3 = *c + mp[x][y];
}
printf("%I64d %I64d %I64d\n", res1, res2, res3);
}
CodeFroces 758C - Unfair Poll的更多相关文章
- 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 ...
- 【找规律】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 ...
- 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 ...
- CodeForces 758 C Unfair Poll
Unfair Poll 题意:一共有n排同学每排同学有m个人, 老师问问题有一个顺序, 先从第一排开始问,问完第一排的所有同学之后,再问第2排的,对于所有排的访问顺序为 1,2,3……n-1,n,n- ...
- C. Unfair Poll
http://codeforces.com/problemset/problem/758/C C. Unfair Poll time limit per test 1 second memory li ...
- 【codeforces 758C】Unfair Poll
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Codeforces 758C:Unfair Poll(思维+模拟)
http://codeforces.com/problemset/problem/758/C 题意:教室里有n列m排,老师上课点名从第一列第一排开始往后点,直到点到第一列第m排,就从第二列第一排开始点 ...
- CF758C Unfair Poll
题意: On the Literature lesson Sergei noticed an awful injustice, it seems that some students are aske ...
- C. Unfair Poll 数学题,
http://codeforces.com/contest/758/problem/C 需要一个能够找到任意一个位置的步数的方法,就能解决三个问题. 预处理出one(row, col)表示第一次经过这 ...
随机推荐
- 交替方向乘子法(ADMM)的原理和流程的白话总结
交替方向乘子法(ADMM)的原理和流程的白话总结 2018年08月27日 14:26:42 qauchangqingwei 阅读数 19925更多 分类专栏: 图像处理 作者:大大大的v链接:ht ...
- Java 常提到的自然序(Natural Ordering)
Natural Ordering常在容器中被提到,和迭代器一起出现. 在Comparable接口的API规范中找到了描述. (https://docs.oracle.com/javase/8/docs ...
- 如何配置数据库镜像<一>
一.简介 “数据库镜像”是Sql Server 2005推出的一个主要用于提高数据库可用率的软件解决方案.镜像是基于每个数据库执行的,仅适用于使用完整恢复模式的数据库.简单恢复模式和大容量日志恢复模式 ...
- 单元操作和仓储模式 repository+unitOfWork
仓储和工作单元模式是用来在数据访问层和业务逻辑层之间创建一个抽象层.应用这些模式,可以帮助用来隔离你的程序在数据存储变化. 在数据源层和业务层之间增加一个repository层进行协调,有如下作用:1 ...
- luogu P4428 [BJOI2018]二进制
luogu 先考虑怎样的二进制串才会被3整除.可以发现如果二进制位第\(0,2,4...2n\)位如果为\(1\),那么在模3意义下为1,如果二进制位第\(1,3,5...2n+1\)位如果为\(1\ ...
- SQL基础:语句执行顺序
SQL入门 select * from table; SQL实战题目 有下面一个表 t ,存储了每个商品类别的成交明细,我们需要通过下面这张表获取订单量大于10对应的类别,并从中取出订单量前3的商品类 ...
- springBoot2.x 支持跨域请求配置
提供三种配置方式: 1.配置过滤器,实现 WebMvcConfigurer接口(springboot2.x的方式) @Configuration public class GlobalCorsConf ...
- SocketClient
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.i ...
- Element 封印
官方网站 https://element.eleme.cn/#/zh-CN 简介 Element 是一套为开发者.设计者和产品经理准备的基于Vue2.0的组件库,提供了配套的设计资源,帮助快速建立网站 ...
- deep_learning_CNN
AI学习笔记——卷积神经网络(CNN) image.png 上篇文章简单地地介绍了神经网络和深度学习,在神经网络中,每一层的每个神经元都与下一层的每个神经元相连(如下图), 这种连接关系叫全连接(Fu ...