Codeforces 392 C Unfair Poll(模拟)
题意:老师点名顺序规则如下:第1排,第2排,……,第n-1排,第n排,第n-1排,……,第2排,第1排,第2排,……,第n-1排,第n排,……对于每排都是从左到右依次点名,问点名k个人后,所有人中最多的点名次数,最少的点名次数,以及位于x排y列处的同学的点名次数。
分析:
1、由于k很大,将第1排,第2排,……,第n-1排,第n排,第n-1排,……,第2排看成一个循环。
2、这个循环中有2*(n-1)*m个人,注意当n=1时,这个循环中有m个人,将这个循环人数记为tmp。
3、利用k/tmp,算出每个人在k/tmp次循环后的点名次数,再按点名规则将第k/tmp + 1次循环中应当被点到名的人涂色即可。
#include<bits/stdc++.h>
#define Min(a, b) ((a < b) ? a : b)
#define Max(a, b) ((a < b) ? b : a)
typedef long long LL;
typedef unsigned long long LLU;
const int INT_INF = 0x3f3f3f3f;
const int INT_M_INF = 0x7f7f7f7f;
const int dr[] = {, , -, , -, -, , };
const int dc[] = {-, , , , -, , -, };
const int MOD = 1e9 + ;
const double pi = acos(-1.0);
const double eps = 1e-;
const int MAXN = + ;
const int MAXT = + ;
using namespace std;
LL ans[MAXN][MAXN];
int main(){
LL n, m, k, x, y;
while(scanf("%I64d%I64d%I64d%I64d%I64d", &n, &m, &k, &x, &y) == ){
memset(ans, , sizeof ans);
LL tmp = (n == ) ? m : * (n - ) * m;
for(LL j = ; j <= m; ++j){
for(LL i = ; i <= n; ++i){
if(i == || i == n) ans[i][j] = k / tmp;
else ans[i][j] = k / tmp * ;
}
}
LL yu = k % tmp;
for(LL i = ; i <= n; ++i){
for(LL j = ; j <= m; ++j){
if(yu){
++ans[i][j];
--yu;
}
else break;
}
}
for(LL i = n - ; i > ; --i){
for(LL j = ; j <= m; ++j){
if(yu){
++ans[i][j];
--yu;
}
else break;
}
}
LL ma = ;
LL mi = 1e18;
for(LL i = ; i <= n; ++i){
for(LL j = ; j <= m; ++j){
ma = Max(ma, ans[i][j]);
mi = Min(mi, ans[i][j]);
}
}
printf("%I64d %I64d %I64d\n", ma, mi, ans[x][y]);
}
return ;
}
Codeforces 392 C Unfair Poll(模拟)的更多相关文章
- CodeForces 758 C Unfair Poll
Unfair Poll 题意:一共有n排同学每排同学有m个人, 老师问问题有一个顺序, 先从第一排开始问,问完第一排的所有同学之后,再问第2排的,对于所有排的访问顺序为 1,2,3……n-1,n,n- ...
- Codeforces 758C:Unfair Poll(思维+模拟)
http://codeforces.com/problemset/problem/758/C 题意:教室里有n列m排,老师上课点名从第一列第一排开始往后点,直到点到第一列第m排,就从第二列第一排开始点 ...
- 【codeforces 758C】Unfair Poll
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 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 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 ...
- C. Unfair Poll
http://codeforces.com/problemset/problem/758/C C. Unfair Poll time limit per test 1 second memory li ...
- 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.158A Next Round (水模拟)
CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...
- Codeforces 747C:Servers(模拟)
http://codeforces.com/problemset/problem/747/C 题意:有n台机器,q个操作.每次操作从ti时间开始,需要ki台机器,花费di的时间.每次选择机器从小到大开 ...
随机推荐
- 安装redis集群
1.搭建集群需要使用到官方提供的ruby脚本. 需要安装ruby的环境. 安装ruby yum install ruby yum install rubygems 2.将ruby包redis-3.0. ...
- struts2--验证器
1.输入验证: --struts2提供了一些基于Xwork Validation Framework的内建验证程序,使用这些验证程序不需要变编程,只要在一个XML文件里进行声明,声明的内容如下: &g ...
- Day9 - H - 最少拦截系统 HDU - 1257
某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于 ...
- Java设计模式之Iterator模式
分类: [java]2013-07-15 10:58 917人阅读 评论(0) 收藏 举报 所谓Iterator模式,即是Iterator为不同的容器提供一个统一的访问方式.本文以java中的容器为例 ...
- Android按返回键退出程序
既然想实现 按两次返回键 退出程序 有两个关键词 一个是 “返回键”,再一个是“退出程序” )先说“退出” 退出相信大家都会 finish(); System.exit(); 为了确保不出现问题,两种 ...
- 第一个Vue.js案例
第一个Vue.js案例 使用Vue有如下几步 引入文件头 加入数据输出框 创建Vue对象,定义数据 案例: <!DOCTYPE html> <html lang="en&q ...
- sklearn中调用PCA算法
sklearn中调用PCA算法 PCA算法是一种数据降维的方法,它可以对于数据进行维度降低,实现提高数据计算和训练的效率,而不丢失数据的重要信息,其sklearn中调用PCA算法的具体操作和代码如下所 ...
- syx学习笔记
SYX复活了,在悲痛之际,希望能让自己获得更多的知识,更有进步,所以留此博客 数学 推荐blog: 1 2 原根表 FFT(快速傅里叶变换) 2019/12/05 √ 博客 blog 题目 Q1 NT ...
- esxi命令行强行关闭虚拟机
目的:强行关闭通过前端界面无法关闭的ESXI虚拟机 环境:esxi5.1-esxi6.5 背景:如果esxi下面某一台vm死机了,并且esxi的控制台卡死不能用,为了不影响同一个esx下其他的vm正常 ...
- 2、MYSQL 基本数据库命令及约束
[注]sql语句注意不要忘了后面的 “ : ”,表示结束符 1.如何登陆数据库服务器 C:\Users\zhg>mysql -uroot -p Enter password: ****** ...