Codeforces 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 l…
C. Unfair Poll time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output On the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others. Seat…
C. Unfair Poll time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output On the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others. Seat…
Unfair Poll 题意:一共有n排同学每排同学有m个人, 老师问问题有一个顺序, 先从第一排开始问,问完第一排的所有同学之后,再问第2排的,对于所有排的访问顺序为 1,2,3……n-1,n,n-1,n-2,……,2,1,2,然后每次访问到新的一排先要问完这一排的所有人才会往下一(目标)排走. 题解:先声明我们开一个数组来记录这一排被询问的总次数,先将k  /= m, 这个代表的是完全访问的次数,即一整排m位同学都问完有几次,如果  完全访问的次数< n, 我们就将前几排全访问次数的人都加上…
http://codeforces.com/problemset/problem/758/C C. Unfair Poll time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output On the Literature lesson Sergei noticed an awful injustice, it seems that some…
C. Unfair Poll time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output On the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others. Seat…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output On the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others. Seating in the class lo…
http://codeforces.com/problemset/problem/758/C 题意:教室里有n列m排,老师上课点名从第一列第一排开始往后点,直到点到第一列第m排,就从第二列第一排开始点,当点完第n列的名之后,接着点第n-1列的名.以此类推,就是从列上来看的话:1,2,3,4,……,n,n-1,n-2,……,1 ,2,…….这样的顺序点名.老师上课总共点k次名,问该课堂最多可以点同一个同学多少次,最少可以点同一个同学多少次,点了位置为(x,y)的同学多少次名. 思路:一遇到这种题目…
题意:老师点名顺序规则如下:第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,算…
题意: On the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others. Seating in the class looks like a rectangle, where n rows with m pupils in each. The teacher asks pupils in the following or…
http://codeforces.com/contest/758/problem/C 需要一个能够找到任意一个位置的步数的方法,就能解决三个问题. 预处理出one(row, col)表示第一次经过这个点,需要的步数. sec(row, col),thr(row, col)分别是第二.三步. 那么,循环节就会产生,记录步数为X, Y, Z,那么,第一二步的差距,和第二三步的差距,分别代表了从下走上去和从上走下来. 那么第4次,就会和第一二步的差距相等 就比如是5.17.23,那么下一步就是35.…
Unfair Poll time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output On the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others. Seating…
A. Holiday Of Equality time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citi…
C. Unfair Poll time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output On the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others. Seat…
传送门 首先可以注意到对于固定的起点 $S$ ,它最终能走到的终点一定是一段区间 这个用反证法容易证明,假设合法区间存在断点,这个点左右都可以作为终点 那么分成区间断点在起点左边和起点右边讨论一下即可,起点本身显然一定可以作为终点 然后现在只要考虑从每个起点出发能走到的最左和最右的位置即可算出答案 首先考虑往右(以下为了方便把第 $i$ 次询问说成第 $i$ 天) 设起点为 $x$ 那么我们可以一直往右走直到遇到某一天刚好询问原本要走的下一个位置,那么此时就要停一次 设连续走了 $y$ 天遇到这…
A. ArielTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/A Description King Triton really likes watching sport competitions on TV. But much more Triton likes watching live competitions. So Triton decides to set up…
A. Mike and palindrome time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the s…
Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = [b1, …
A. Mike and palindrome time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the s…
F. Bear and Fair Set 题目连接: http://www.codeforces.com/contest/628/problem/F Description Limak is a grizzly bear. He is big and dreadful. You were chilling in the forest when you suddenly met him. It's very unfortunate for you. He will eat all your coo…
select.poll.epoll之间的区别总结 05/05. 2014 select,poll,epoll都是IO多路复用的机制.I/O多路复用就通过一种机制,可以监视多个描述符,一旦某个描述符就绪(一般是读就绪或者写就绪),能够通知程序进行相应的读写操作.但select,poll,epoll本质上都是同步I/O,因为他们都需要在读写事件就绪后自己负责进行读写,也就是说这个读写过程是阻塞的,而异步I/O则无需自己负责进行读写,异步I/O的实现会负责把数据从内核拷贝到用户空间.关于这三种IO多路…
注:本文是对众多博客的学习和总结,可能存在理解错误.请带着怀疑的眼光,同时如果有错误希望能指出. 同步IO和异步IO,阻塞IO和非阻塞IO分别是什么,到底有什么区别?不同的人在不同的上下文下给出的答案是不同的.所以先限定一下本文的上下文. 本文讨论的背景是Linux环境下的network IO. 一 概念说明 在进行解释之前,首先要说明几个概念:- 用户空间和内核空间- 进程切换- 进程的阻塞- 文件描述符- 缓存 I/O 用户空间与内核空间 现在操作系统都是采用虚拟存储器,那么对32位操作系统…
select.poll.epoll简介 epoll跟select都能提供多路I/O复用的解决方案.在现在的Linux内核里有都能够支持,其中epoll是Linux所特有,而select则应该是POSIX所规定,一般操作系统均有实现 select: select本质上是通过设置或者检查存放fd标志位的数据结构来进行下一步处理.这样所带来的缺点是: 1. 单个进程可监视的fd数量被限制,即能监听端口的大小有限. 一般来说这个数目和系统内存关系很大,具体数目可以cat /proc/sys/fs/fil…
介绍和比较 http://www.cnblogs.com/maociping/p/5132583.html 比较 http://www.dataguru.cn/thread-336032-1-1.html select select本质上是通过设置或者检查存放fd标志位的数据结构来进行下一步处理.这样所带来的缺点是: 1 单个进程可监视的fd数量被限制 2 需要维护一个用来存放大量fd的数据结构,这样会使得用户空间和内核空间在传递该结构时复制开销大 3 对socket进行扫描时是线性扫描 pol…
poll函数与select函数差不多 函数原型: #include <poll.h> int poll(struct pollfd fd[], nfds_t nfds, int timeout); struct pollfd的结构如下: struct pollfd{ int fd: // 文件描述符 short event:// 请求的事件 short revent:// 返回的事件 } 每个pollfd结构体指定了一个被监视的文件描述符.第一个参数是一个数组,即poll函数可以监视多个文件描…
使用POLL机制代替linux输入子系统(input subsystem)之按键输入和LED控制中的异步通知,实现同样的效果. 1.代码 只简单修改input_subsys_test.c, input_subsys_drv.c不变 input_subsys_test.c #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> #include <…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's…
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is…