题意:给定一个手机,然后一共有 n 个app,告诉你每个屏幕最多放 k 个,现在要你运行 m 个app,每次都从第一个屏幕开始滑动,每运行一个,它就和前一个交换位置,第一个就不换了,现在问你要滑动多少次. 析:这个题,没什么算法,就是模拟呗,不过要注意时间,不能TLE,所以我们就得提前把所有的位置都存下来,让查找的时间变成 O(1),否则就会超时,可以用两个数组,也可以用map,一个存编号,一个存位置, 然后运行完后再交换就行了. 代码如下: #include <iostream> #incl…
C. Anya and Smartphone time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Anya has bought a new smartphone that uses Berdroid operating system. The smartphone menu has exactly n applications,…
C. Anya and Smartphone time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Anya has bought a new smartphone that uses Berdroid operating system. The smartphone menu has exactly n applications,…
C. Anya and Smartphone time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Anya has bought a new smartphone that uses Berdroid operating system. The smartphone menu has exactly n applications,…
C. Anya and Ghosts time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lo…
C. Anya and Ghosts time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lo…
A. Vitaly and Strings 题意:两个字符串s,t,是否存在满足:s < r < t 的r字符串 字符转处理:字典序排序 很巧妙的方法,因为s < t,只要找比t字典序稍微小一点的和s比较就行了 具体方法和数字减1相类似,从"个位"减1,如果是0,从前面借1 !strcmp (t, s):如果t < s 或者 t > s (不可能)则输出,t == s 则输出NO #include <cstdio> #include <i…
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, 然后接下来的t秒需要的蜡烛都燃烧着,超过t秒,每减少一秒灭一支蜡烛,好!!! 详细解释:http://blog.csdn.net/kalilili/article/details/43412385 */ #include <cstdio> #include <algorithm> #i…
Servers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are n servers in a laboratory, each of them can perform tasks. Each server has a unique id - integer from 1 to n. It is known…
C. Thor time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated…