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的时间.每次选择机器从小到大开 ...
随机推荐
- tomcat web服务的搭建
在安装tomcat之前必须安装jdk 安装配置jdk 1.查看虚拟机中是否已安装java包 # rpm -qa | grep java 如果查找已安装java包,先卸载全部的openjdk #rpm ...
- IOS 导航栏颜色 标题
修改导航栏颜 #define COLOR_TOMATO [UIColor colorWithRed:255/255.0f green:99/255.0f blue:71/255.0f alpha ...
- 黑客的探路狗ReconDog网站信息探测收集工具
工具下载地址:http://pan.baidu.com/s/1pLJnBLL 密码:gqlz OR https://github.com/UltimateHackers/ReconDog 下载并 ...
- 【C#】关于左移/右移运算符的使用
吐槽先~为什么我的老师大学时候没教过我这东西 - -. 继续送栗子: 比如 “(1+2)<<3” 你们猜等于几~ Debug.Log((1+2)<<3)之后输出的是“24”. ...
- 图片FormData上传
var base64String = /*base64图片串*/; //这里对base64串进行操作,去掉url头,并转换为byte var bytes = window.atob(base64Str ...
- spring源码第一章_获取源码并将源码转为eclipse工程
1.通过http://gitforwindows.org/下载github 2.通过http://services.gradle.org/distributions/下载gradle:gardle类似 ...
- django-redis和redis连接
redis连接 简单连接 import redis r = redis.Redis(host=) r.set('foo', 'Bar') print r.get('foo') 连接池 import r ...
- Linux 内核 编译模块
背景: 由于调试内核或者由于分区大小限制,有时候内核组件不一定完全需要编进内核中. 所以,在开发中经常将内核组件编译成为模块,等到在恰当的时机加载. 概览: Linux内核模块的编译方法有两种: 1. ...
- MIT课程
8.02 Physics II (电磁学基础) Introduction to electromagnetism and electrostatics: electric charge, Coulo ...
- spoj694--Distinct Substrings
个人第一道后缀数组题目.对于每一个后缀suffix(i),都有len-sa[i]个前缀(也即有len-sa[i]个不同的字符串),其中与排名前一位的后缀有height[i]个共同的前缀,最后所得到的新 ...