Unfair Poll

题意:一共有n排同学每排同学有m个人, 老师问问题有一个顺序, 先从第一排开始问,问完第一排的所有同学之后,再问第2排的,对于所有排的访问顺序为 1,2,3……n-1,n,n-1,n-2,……,2,1,2,然后每次访问到新的一排先要问完这一排的所有人才会往下一(目标)排走。

题解:先声明我们开一个数组来记录这一排被询问的总次数,先将k  /= m, 这个代表的是完全访问的次数,即一整排m位同学都问完有几次,如果  完全访问的次数< n, 我们就将前几排全访问次数的人都加上m,并且将剩下的访问次数都塞到一下排就好了,如果完全访问次数大于n了之后,发现除了第一次转移的次数位n-1排, 我们再对 k/=(n-1) 处理出来, 然后判断奇偶性来决定最后一次是从上到下还是从下到上,对于所有的排都加上次数,最后再把刚开始的访问次数塞到目标排就好了。

n==1的话,对于上述解法要特殊讨论因为除数或者模数不能为0。

代码:

 #include<bits/stdc++.h>
using namespace std;
#define Fopen freopen("_in.txt","r",stdin); freopen("_out.txt","w",stdout);
#define LL long long
#define ULL unsigned LL
#define fi first
#define se second
#define pb push_back
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
typedef pair<int,int> pll;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const LL mod = (int)1e9+;
const int N = 2e5 + ;
LL n, m, x, y;
LL k, ans1, ans2 = INF, ans3;
LL cnt[N];
int main(){
scanf("%I64d%I64d%I64d%I64d%I64d", &n, &m, &k, &x, &y);
LL c1, c2;
c1 = k/m;
c2 = k%m;
swap(c1, k);
if(k < n){
for(int i = ; i <= k; i++) cnt[i] = m;
cnt[k+] = c2;
}
else {
for(int i = ; i <= n; i++) cnt[i] = m;
k -= n;
if(n != ){
LL t = n-;
LL z = k / t;
LL lf = k % t;
LL t1 = z-z/;
for(int i = ; i < n; i++) cnt[i] += t1*m;
for(int i = ; i <= n; i++) cnt[i] += z/ * m;
if(z&1ll){
int g = ;
for(int i = ; i <= n, lf > ; i++, lf--) cnt[i] += m, g = i;
cnt[++g] += c2;
}
else{
int g = n;
for(int i = n-; i >= , lf > ; i--, lf--) cnt[i] += m, g = i;
cnt[--g] += c2;
}
}
else cnt[] = c1;
}
for(int i = ; i <= n; i++){
if(cnt[i] == ) {ans2 = ; continue;}
if(i == x) {
LL lf = cnt[i]%m;
ans3 = cnt[i]/m;
if(lf >= y) ans3++;
};
LL t1 = cnt[i]/m;
if(cnt[i]%m) t1++;
ans1 = max(ans1, t1);
LL t2 = cnt[i]/m;
ans2 = min(ans2, t2);
} printf("%I64d %I64d %I64d", ans1, ans2, ans3);
return ;
}

758 C

CodeForces 758 C Unfair Poll的更多相关文章

  1. 【codeforces 758C】Unfair Poll

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  2. Codeforces 758C:Unfair Poll(思维+模拟)

    http://codeforces.com/problemset/problem/758/C 题意:教室里有n列m排,老师上课点名从第一列第一排开始往后点,直到点到第一列第m排,就从第二列第一排开始点 ...

  3. Codeforces 392 C Unfair Poll(模拟)

    题意:老师点名顺序规则如下:第1排,第2排,……,第n-1排,第n排,第n-1排,……,第2排,第1排,第2排,……,第n-1排,第n排,……对于每排都是从左到右依次点名,问点名k个人后,所有人中最多 ...

  4. 【找规律】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 ...

  5. 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 ...

  6. C. Unfair Poll

    http://codeforces.com/problemset/problem/758/C C. Unfair Poll time limit per test 1 second memory li ...

  7. 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 ...

  8. C. Unfair Poll 数学题,

    http://codeforces.com/contest/758/problem/C 需要一个能够找到任意一个位置的步数的方法,就能解决三个问题. 预处理出one(row, col)表示第一次经过这 ...

  9. CF758C Unfair Poll

    题意: On the Literature lesson Sergei noticed an awful injustice, it seems that some students are aske ...

随机推荐

  1. Apache ActiveMQ 实践 <一>

    一.下载最新版本 ActiveMq http://activemq.apache.org/activemq-5152-release.html,下载目录如下: 二.创建项目 1.普通项目 添加 jar ...

  2. 使用eclipse编写和运行java程序(基础)

    1.首先java程序的运行你需要下载和安装JDK,这是java运行的必备环境. 2.在桌面上找到eclipes,双击打开. 3.在eclipes启动的过程中,会弹出一个窗口,让你填写java工作区的保 ...

  3. Oracle中ROWNUM伪列和ROWID伪列的用法与区别

    做过Oracle分页的人都知道由于Oracle中没有像MySql中limit函数以及SQLServer中的top关键字等,所以只能通过伪列的方式去满足分页功能,在此,不谈分页方法,只从根本上去介绍这两 ...

  4. 面向对象---prototype、__proto__、实例化对象三者之间的关系

    1.构造函数 a.什么是构造函数? 解释:通过关键字new 创建的函数叫做构造函数 作用:用来创建一个对象 废话少说直接上代码,首先我们还是创建一个构造函数人类 然后我们在创建两个实例,一个凡尘 一个 ...

  5. Python pip包管理器安装第三方库超时解决方案

    一.国内镜像安装 使用方法:pip install --index 镜像网站 第三方库名 二.镜像网站 http://pypi.douban.com/simple/ 豆瓣 http://mirrors ...

  6. 洛谷 P2572 [SCOI2010]序列操作

    题意简述 维护一个序列,支持如下操作 把[a, b]区间内的所有数全变成0 把[a, b]区间内的所有数全变成1 把[a,b]区间内所有的0变成1,所有的1变成0 询问[a, b]区间内总共有多少个1 ...

  7. Spring 2017 Assignments1

    一.作业要求 原版:http://cs231n.github.io/assignments2017/assignment1/ 翻译:http://www.mooc.ai/course/268/lear ...

  8. 如何以python风格高逼格的改成购物车逻辑

    之前有一篇博文写到关于购物车的业务逻辑,分别运用cookie和redis存储未登录和登录用户的购物车数据,虽然已经很好的完成了业务逻辑,但是会发现代码的冗余很严重,也不够具有python特色,今天就让 ...

  9. exlipse php 插件安装地址

    以前的exlipse PHP插件老是有问题,下面这个地址可以使用. http://www.phpsrc.org/eclipse/pti/

  10. QMS 的趨勢概述

    自泰勒Taylor提出的科学管理被奉行后,制造业的分工已然成形,而产品不再是由工匠单独负责完成.为确保产品的质量,产品在完工后的检验为确保瑕疵品不外流出给客户的必要关卡.然而当产品依靠检验结果并无法减 ...