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)表示第一次经过这 ...
随机推荐
- shell中防止意外发生的两个实用的设置
set -o nounset set -o errexit set -o nounset 在默认情况下,遇到不存在的变量,会忽略并继续执行,而这往往不符合预期,加入该选项,可以避免恶果扩大,终止脚本的 ...
- hdu 6601 区间条件极值 - 区间 最大 三角形周长
题目传送门//res tp hdu 目的 对长度为n的区间,给定q个子区间,求其元素能构成三角形的最大周长.有多组测试. n 1e5 q 1e5 ai [1,1e9] (i∈[1,n]); 数据结构 ...
- C++变量的声明和定义
1.变量的定义:变量的定义用于为变量分配存储控件,还可以为变量指定初始值.在一个程序中,变量有且仅有一个定义. 2.变量的声明:用于向程序表名变量的类型和名字.程序中变量可以声明多次,但只能定义一次. ...
- OpenVZ平台 Google BBR加速
前言 一直以来用的都是搬瓦工的VPS,不得不说比国内那些大厂的性价比高得不知道哪里去了. 当做梯子来用的话搬瓦工年付19.9美元的方案就够用了,网上还有一些官方优惠码(折扣6%: BWH1ZBPV ...
- Struts框架的使用初步
Struts框架的使用初步: A:Apache下载struts.2.1.8.rar包. B:解压空工程,进入apps目录. C:将struts2的基本jar包拷到工程的lib目录中. D:配置web. ...
- C语言无法使用引用,一定要使用怎么办? ------指针的指针做参数
#include <stdio.h> #include <stdlib.h> #include <string.h> void fun1(char** s); vo ...
- Hive SQL查询效率提升之Analyze方案的实施
0.简介 Analyze,分析表(也称为计算统计信息)是一种内置的Hive操作,可以执行该操作来收集表上的元数据信息.这可以极大的改善表上的查询时间,因为它收集构成表中数据的行计数,文件计数和文件大小 ...
- go之环境安装
1)Linux安装 https://studygolang.com/dl # 在 ~ 下创建 go 文件夹,并进入 go 文件夹 mkdir ~/go && cd ~/go 下载的 g ...
- vue-$watch属性方法
特性 https://www.cnblogs.com/widgetbox/p/8954162.html https://segmentfault.com/a/1190000012948175?utm_ ...
- JavaScript笔记(4)
3.JavaScript事件 定义 1.事件是JavaScript事先定义好的 2.JavaScript中事件大多都是以"on--"开头的 3.事件由三要素组成:事件源.事件名.事 ...