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)表示第一次经过这 ...
随机推荐
- double write 双写
Oracle 8KB Postgresql 8KB MySQL Innodb 16KB buffer page block首先,要DML数据,需要先把page读取到index page中,之后对内存中 ...
- c++学习笔记之函数重载和模板理解
1.函数重载: C++ 不允许变量重名,但是允许多个函数取相同的名字,只要参数表不同即可,这叫作函数的重载(其英文是 overload).重载就是装载多种东西的意思,即同一个事物能完成不同功能. 所谓 ...
- AI面试必备/深度学习100问1-50题答案解析
AI面试必备/深度学习100问1-50题答案解析 2018年09月04日 15:42:07 刀客123 阅读数 2020更多 分类专栏: 机器学习 转载:https://blog.csdn.net ...
- inline元素、block元素
inline元素 不会独占一行,相邻的行内元素会排列在同一行内,直到一行排不下才会换行 高.行高.以及外边距和内边距不可改变 宽度就是它的文字或图片的宽度,不可改变,随元素内容变化而变化 内联元素只能 ...
- O035、Nova Suspend / Rescue 操作详解
参考https://www.cnblogs.com/CloudMan6/p/5503501.html Suspend / Resume 有时候需要长时间暂停 instance , 可以通过 S ...
- 【科创人·独家】连续创业者高春辉的这六年:高强度投入打造全球领先的IP数据库
您能看到:高春辉的创业观,IPIP.NET半程复盘及未来规划,连续创业的体验,小众产品趣事 您看不到:往年创业的回顾,技术干货,受制于篇幅忍痛割舍的精彩观点 文末彩蛋:<与雷军的分歧并非否定电商 ...
- 记录FTPClient超时处理的相关问题(转)
https://www.cnblogs.com/dasusu/p/10006899.html 记录 FTPClient 超时处理的相关问题 apache 有个开源库:commons-net,这个开 ...
- OSCP-Kioptrix2014-1 环境搭建
环境搭建 该系列文章参考 : https://www.youtube.com/watch?v=bWM0BCQ5q1o&list=PL9WW-prbqvGzHsGK_OqTyYWbCZjucpI ...
- go语言入门(5)工程管理
在工程中不会简单到只有一个源代码文件,且源文件之间会有相互的依赖关系,早期Go语言使用makefile作为工程管理的临时方案,后来的Go命令行工具的革命性之处在于彻底消除了工程文件的概念,完全用目录结 ...
- 第十章、datetime模块
目录 第十章.datetime模块 一.datetime 模块 第十章.datetime模块 一.datetime 模块 import datetime#返回当前时间 print(datetime.d ...