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)表示第一次经过这 ...
随机推荐
- 【Python】【demo实验9】【练习实例】【三数排序】
原题: 输入三个整数x,y,z,请把这三个数由小到大输出. 我的解法: #!/usr/bin/python # encoding=utf-8 # -*- coding: UTF-8 -*- # 输入三 ...
- Oracle的基本操作-修改表结构、数据的增删改查
创建一个person表 create table person( pid ), pname ) ); 添加一列 ); 修改列类型 ); 修改列名称 alter table person rename ...
- Jenkins+SVN持续环境搭建
需要三台不同环境的服务器,SVN.Jenkins.Tomcat 1.SVN搭建 1.Subversion服务器(SVN服务器) 2.项目对应的版本库 3.版本库中钩子程序(用于触发构建命令) 在我以前 ...
- 基于Centos 搭建Jenkins环境
⒈简介 Jenkins 是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能. ⒉Java安装 首先我们需要准备 ...
- Android Application的Gradle说明
//引入插件 apply plugin: 'com.android.application' android { compileSdkVersion 29 buildToolsVersion &quo ...
- MySQL如何利用索引优化ORDER BY排序语
MySQL索引通常是被用于提高WHERE条件的数据行匹配或者执行联结操作时匹配其它表的数据行的搜索速度. MySQL也能利用索引来快速地执行ORDER BY和GROUP BY语句的排序和分组操作. 通 ...
- python商城项目总结
项目概括 本项目用于针对Django框架的练习,主要分为前端和后端两部分.前端负责用户注册.登录.商品展示以及添加购物车和显示订单列表的功能:后端负责会员信息.商品类别.商品信息的增删改查以及订单状态 ...
- CSS基础布局
目录 css基础布局 1.布局相关的标签 2.盒子模型 2-1 什么是盒子模型 2-2 块级元素和内联元素(行内元素) 2-3 盒子模型之间的关系 盒子模型相关CSS属性 3.浮动 3-1 什么是浮动 ...
- List 集合 一行4个排序
List<string> list = new List<string>(); ; i < ; i++) { list.Add(i.ToString()); } int ...
- vue页面中图片不显示解决
在做新版组态界面的时候,用vue框架实现,在配置页面图片的时候发现有一张图片明明页面输入的路径是对的可是图片就是不显示出来 现象: network页面资源也不报错,而且状态码竟然还是200,点prev ...