记录CodeForces刷题C语言QAQ
有一台电脑,在活跃状态下,每秒钟耗能 P 1 P1 P1,在没人碰之后的 T 1 T1 T1 秒后,进入休息状态,每秒钟耗能 P 2 P2 P2,如果再有 T 2 T2 T2 秒没人碰的话,就会进入睡眠状态,每秒钟耗能 P 3 P3 P3。
给你这个人碰电脑的区间时间,问你这台电脑的耗能是多少
感谢@Dreamer丶杨 提供的翻译
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes $ P_{1} $ watt per minute. $ T_{1} $ minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to $ P_{2} $ watt per minute. Finally, after $ T_{2} $ minutes from the start of the screensaver, laptop switches to the “sleep” mode and consumes $ P_{3} $ watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom’s work with the laptop can be divided into $ n $ time periods $ [l_{1},r_{1}],[l_{2},r_{2}],…,[l_{n},r_{n}] $ . During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period $ [l_{1},r_{n}] $ .
The first line contains 6 integer numbers $ n $ , $ P_{1} $ , $ P_{2} $ , $ P_{3} $ , $ T_{1} $ , $ T_{2} $ ( $ 1<=n<=100,0<=P_{1},P_{2},P_{3}<=100,1<=T_{1},T_{2}<=60 $ ). The following $ n $ lines contain description of Tom’s work. Each $ i $ -th of these lines contains two space-separated integers $ l_{i} $ and $ r_{i} $ ( $ 0<=l_{i} Output the answer to the problem. 把数列中一个数加上 d d d 算作一次操作,求最少几次操作能把这个数列变为递增数列。 输入共 2 2 2 行。 第一行 2 2 2 个整数 n n n 和 d d d, n n n 表示数列中数的数量, d d d 含义如题目所示。 第二行 n n n 个整数,表示原始数列。 一行一个整数 m m m,表示最少 m m m 次操作能把这个数列变为递增数列。 A sequence $ a_{0},a_{1},…,a_{t-1} $ is called increasing if $ a_{i-1} You are given a sequence $ b_{0},b_{1},…,b_{n-1} $ and a positive integer $ d $ . In each move you may choose one element of the given sequence and add $ d $ to it. What is the least number of moves required to make the given sequence increasing? The first line of the input contains two integer numbers $ n $ and $ d $ ( $ 2<=n<=2000,1<=d<=10^{6} $ ). The second line contains space separated sequence $ b_{0},b_{1},…,b_{n-1} $ ( $ 1<=b_{i}<=10^{6} $ ). Output the minimal number of moves needed to make the sequence increasing. 给定一个 3 × 3 3 \times 3 3×3 的矩形,每个元素不是 There is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been preparing special agent Pearlo for many years. When, finally, Pearlo learned all secrets of espionage, he penetrated into the Potatoland territory and reached the secret base. Now he is standing at the entrance, but to get inside he need to pass combination lock. Minute ago one of the workers entered the password on the terminal and opened the door. The terminal is a square digital keyboard $ 3×3 $ with digits from $ 1 $ to $ 9 $ . Pearlo knows that the password consists from distinct digits and is probably symmetric with respect to the central button of the terminal. He has heat sensor which allowed him to detect the digits which the worker pressed. Now he wants to check whether the password entered by the worker is symmetric with respect to the central button of the terminal. This fact can Help Pearlo to reduce the number of different possible password combinations. Input contains the matrix of three rows of three symbols each. Symbol «X» means that the corresponding button was pressed, and «.» means that is was not pressed. The matrix may contain no «X», also it may contain no «.». Print YES if the password is symmetric with respect to the central button of the terminal and NO otherwise. If you are not familiar with the term «central symmetry», you may look into http://en.wikipedia.org/wiki/Central_symmetry 给定一 N × M N \times M N×M 规模的矩阵,输出最小的包含所有 一行两个整数, N N N 和 M M M 。 然后一个 N × M N \times M N×M 大小的矩阵。 输出最小的包含所有 1 ≤ N , M ≤ 50 1 \leq N,M \leq 50 1≤N,M≤50。 A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with $ n $ rows and $ m $ columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland. Now Bob has to send his picture by post, but because of the world economic crisis and high oil prices, he wants to send his creation, but to spend as little money as possible. For each sent square of paper (no matter whether it is shaded or not) Bob has to pay 3.14 burles. Please, help Bob cut out of his masterpiece a rectangle of the minimum cost, that will contain all the shaded squares. The rectangle’s sides should be parallel to the sheet’s sides. The first line of the input data contains numbers $ n $ and $ m $ ( $ 1<=n,m<=50 $ ), $ n $ — amount of lines, and $ m $ — amount of columns on Bob’s sheet. The following $ n $ lines contain $ m $ characters each. Character «.» stands for a non-shaded square on the sheet, and «*» — for a shaded square. It is guaranteed that Bob has shaded at least one square. Output the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better. 根据一项新的 ISO 标准,每一个国家的国旗应该是一个 n × m n\times m n×m 的格子场,其中每个格子最多有 10 10 10 种不同的颜色。并且国旗应该有条纹:旗帜的每一行应包含相同颜色的方块,相邻的行的颜色应该是不同的。Berland 政府要求你找出他们的国旗是否符合新的 ISO 标准。 输入的第一行包含数 n n n 和 m m m,其中 n n n 为行数, m m m 为列数。 接下来是对旗的描述:以下 n n n 行中的每一行包含 m m m 个字符。每个字符是 0 0 0 到 9 9 9 之间的数字,代表相应正方形的颜色。 如果国旗符合标准就输出 According to a new ISO standard, a flag of every country should have a chequered field $ n×m $ , each square should be of one of 10 colours, and the flag should be «striped»: each horizontal row of the flag should contain squares of the same colour, and the colours of adjacent horizontal rows should be different. Berland’s government asked you to find out whether their flag meets the new ISO standard. The first line of the input contains numbers $ n $ and $ m $ ( $ 1<=n,m<=100 $ ), $ n $ — the amount of rows, $ m $ — the amount of columns on the flag of Berland. Then there follows the description of the flag: each of the following $ n $ lines contain $ m $ characters. Each character is a digit between 0 and 9, and stands for the colour of the corresponding square. Output YES, if the flag meets the new ISO standard, and NO otherwise.输出格式
样例 #1
样例输入 #1
1 3 2 1 5 10
0 10
样例输出 #1
30
样例 #2
样例输入 #2
2 8 4 2 5 10
20 30
50 100
样例输出 #2
570
代码如下:
#include
二、Increasing Sequence
题面翻译
题面描述
输入格式
输出格式
题目描述
输入格式
输出格式
样例 #1
样例输入 #1
4 2
1 3 3 2
样例输出 #1
3
代码如下:
#include
三、Super Agent
题面翻译
X
就是.
,问这个矩形是否是中心对称的。题目描述
输入格式
输出格式
样例 #1
样例输入 #1
XX.
...
.XX
样例输出 #1
YES
样例 #2
样例输入 #2
X.X
X..
...
样例输出 #2
NO
提示
代码如下:
#include
四、Letter
题面翻译
题目描述
*
的矩阵。输入格式
输出格式
*
的矩阵。数据范围
题目描述
输入格式
输出格式
样例 #1
样例输入 #1
6 7
.......
..***..
..*....
..***..
..*....
..***..
样例输出 #1
***
*..
***
*..
***
样例 #2
样例输入 #2
3 3
***
*.*
***
样例输出 #2
***
*.*
***
代码如下:
#include
五、Flag
题面翻译
题目描述
输入格式
输出格式
YES
,否则输出 NO
。题目描述
输入格式
输出格式
样例 #1
样例输入 #1
3 3
000
111
222
样例输出 #1
YES
样例 #2
样例输入 #2
3 3
000
000
111
样例输出 #2
NO
样例 #3
样例输入 #3
3 3
000
111
002
样例输出 #3
NO
代码如下:
#include