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. 【Java笔记】【Java核心技术卷1】chapter3 D4变量

    package chapter3; public class D4变量 { public static final int BBB=100; //类常量 public static void main ...

  2. Flink 源码解析 —— 源码编译运行

    更新一篇知识星球里面的源码分析文章,去年写的,周末自己录了个视频,大家看下效果好吗?如果好的话,后面补录发在知识星球里面的其他源码解析文章. 前言 之前自己本地 clone 了 Flink 的源码,编 ...

  3. 2月11日 阿里巴巴Java开发手册 读后感

    该手册分为几个部分: 印象深刻的几点: (五)集合处理 2.[强制]ArrayList的subList结果不可强转成ArrayList,否则会抛出ClassCastException 异常:java. ...

  4. ssh的执行流畅

    SSH运行流程 1. 服务器启动,创建Struts2的Filter控制器,创建Spring容器对象. 实例化Struts2控制器时,加载struts.xml,struts-default.xml,de ...

  5. java面向对象中的集合

    1.学习集合的原因? A.数组是面向过程的,集合是面向对象的. B.集合是类,具备类的封装,继承,多态...超强功能. C.数组是固定长度,集合是可变长度 D.数组没办法获得真实的元素个数:集合可以. ...

  6. 简易数据分析 10 | Web Scraper 翻页——抓取「滚动加载」类型网页

    这是简易数据分析系列的第 10 篇文章. 友情提示:这一篇文章的内容较多,信息量比较大,希望大家学习的时候多看几遍. 我们在刷朋友圈刷微博的时候,总会强调一个『刷』字,因为看动态的时候,当把内容拉到屏 ...

  7. 重读《学习JavaScript数据结构与算法-第三版》- 第3章 数组(一)

    定场诗 大将生来胆气豪,腰横秋水雁翎刀. 风吹鼍鼓山河动,电闪旌旗日月高. 天上麒麟原有种,穴中蝼蚁岂能逃. 太平待诏归来日,朕与先生解战袍. 此处应该有掌声... 前言 读<学习JavaScr ...

  8. Navicat连接MYsql报错

    在Windows中安装mysql8后,使用Navicat连接数据库是出现“ Client does not support authentication protocol requested by s ...

  9. Java中使用RestFul接口上传图片到阿里云OSS服务器

    1.接口方法 import java.io.IOException; import javax.servlet.http.HttpServletRequest; import org.springfr ...

  10. Python+Selenium - Web自动化测试(一):环境搭建

    清单列表: Python 3x Selenium Chrome Pycharm 一.Python的安装: Python官网下载地址:https://www.python.org/ 1.  进入官网地址 ...