-
【Codeforces Round#620 (Div. 2)】C. Air Conditioner 题解
题目链接:C. Air Conditioner题目Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers’ preferred temperature ranges! Looking through the r...…
-
【Codeforces Round#620 (Div. 2)】B. Longest Palindrome 题解
题目链接:B. Longest Palindrome题目Returning back to problem solving, Gildong is now studying about palindromes. He learned that a palindrome is a string that is the same as its reverse. For example, strings “pop”, “noon”, “x”, and “kkkkkk” are palindromes, while strings “moon”, “tv”, and “abab” are not...…
-
【Codeforces Round#620 (Div. 2)】A. Two Rabbits 题解
题目链接:A. Two Rabbits题目Being tired of participating in too many Codeforces rounds, Gildong decided to take some rest in a park. He sat down on a bench, and soon he found two rabbits hopping around. One of the rabbits was taller than the other.He noticed that the two rabbits were hopping towards eac...…
-
【Codeforces Round#593 (Div. 2)】B. Alice and the List of Presents 题解 - 快速幂
题目链接:B. Alice and the List of Presents题目Alice got many presents these days. So she decided to pack them into boxes and send them to her friends.There are n kinds of presents. Presents of one kind are identical (i.e. there is no way to distinguish two gifts of the same kind). Presents of different...…
-
【Codeforces Round#593 (Div. 2)】A. Stones 题解
题目链接:A. Stones题目Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains a stones, the second of them contains b stones and the third of them contains c stones.Each time she can do one of two operations: take one stone from the first heap and two...…
-
【Codeforces Round#587 (Div. 3)】D. Swords 题解
题目链接:D. Swords题目There were n types of swords in the theater basement which had been used during the plays. Moreover there were exactly x swords of each type. y people have broken into the theater basement and each of them has taken exactly z swords of some single type. Note that different people ...…
-
【Codeforces Round#618 (Div. 2)】C. Anu Has a Function 题解
题目链接:C. Anu Has a Function题目Anu has created her own function f: f(x,y)=(x|y)−y where | denotes the bitwise OR operation. For example, f(11,6)=(11|6)−6=15−6=9. It can be proved that for any nonnegative numbers x and y value of f(x,y) is also nonnegative.She would like to research more about this f...…
-
【Codeforces Round#618 (Div. 2)】B. Assigning to Classes 题解
题目链接:B. Assigning to Classes题目Reminder: the median of the array [a1,a2,…,a2k+1] of odd number of elements is defined as follows: let [b1,b2,…,b2k+1] be the elements of the array in the sorted order. Then median of this array is equal to bk+1.There are 2n students, the i-th student has skill level...…
-
【Codeforces Round#618 (Div. 2)】A. Non-zero 题解
题目链接:A. Non-zero题目Guy-Manuel and Thomas have an array a of n integers [a1,a2,…,an]. In one step they can add 1 to any element of the array. Formally, in one step they can choose any integer index i (1≤i≤n) and do ai:=ai+1.If either the sum or the product of all elements in the array is equal to z...…
-
【Codeforces Round#617 (Div. 3)】D. Fight with Monsters 题解
题目链接:D. Fight with Monsters题目There are n monsters standing in a row numbered from 1 to n. The i-th monster has hi health points (hp). You have your attack power equal to a hp and your opponent has his attack power equal to b hp.You and your opponent are fighting these monsters. Firstly, you and y...…
-
【Codeforces Round#617 (Div. 3)】C. Yet Another Walking Robot 题解【奇妙的记录方式
题目链接:C. Yet Another Walking Robot题目There is a robot on a coordinate plane. Initially, the robot is located at the point (0,0). Its path is described as a string s of length n consisting of characters ‘L’, ‘R’, ‘U’, ‘D’.Each of these characters corresponds to some move: ‘L’ (left): means that the...…
-
【Codeforces Round#617 (Div. 3)】B. Food Buying 题解
题目链接:B. Food Buying题目Mishka wants to buy some food in the nearby shop. Initially, he has s burles on his card.Mishka can perform the following operation any number of times (possibly, zero): choose some positive integer number 1≤x≤s, buy food that costs exactly x burles and obtain ⌊x/10⌋ burles a...…
-
【Codeforces Round#617 (Div. 3)】A. Array with Odd Sum 题解
题目链接:A. Array with Odd Sum题目You are given an array a consisting of n integers.In one move, you can choose two indices 1≤i,j≤n such that i≠j and set ai:=aj. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := i...…
-
StandardTemplateLibrary Plus
对于 STL 完全不理解的可以先看看基础篇:StandardTemplateLibrary 本章掌握了后,还有关于 <iomanip> 和字符串和数组转换等内容的 STL 补充包目录 目录 简介 getline(cin, string()) 函数 string 的 .c_str() 方法和 sscanf() 函数 sscanf() stringstream 对象 最后再给你们整几个栗子 cout « fixed « setprecision(2) « double(); 控制输出位数 二元组 pa...…
-
【莫名其妙】1014 福尔摩斯的约会 (20分) 题解
题目链接:1014 福尔摩斯的约会 (20分)题目大侦探福尔摩斯接到一张奇怪的字条:我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm。大侦探很快就明白了,字条上奇怪的乱码实际上就是约会的时间星期四 14:04,因为前面两字符串中第 1 对相同的大写英文字母(大小写有区分)是第 4 个字母 D,代表星期四;第 2 对相同的字符是 E ,那是第 5 个英文字母,代表一天里的第 14 个钟头(于是一天的 0 点到 23 点由数字 0 到 9、以及大写字母 A 到 N 表示);后面两字符串第 1 对相同的英文...…
-
【一败涂地】L1-043 阅览室 (20分) 题解
题目链接:L1-043 阅览室 (20分)题目天梯图书阅览室请你编写一个简单的图书借阅统计程序。当读者借书时,管理员输入书号并按下S键,程序开始计时;当读者还书时,管理员输入书号并按下E键,程序结束计时。书号为不超过1000的正整数。当管理员将0作为书号输入时,表示一天工作结束,你的程序应输出当天的读者借书次数和平均阅读时间。注意:由于线路偶尔会有故障,可能出现不完整的纪录,即只有S没有E,或者只有E没有S的纪录,系统应能自动忽略这种无效纪录。另外,题目保证书号是书的唯一标识,同一本书在任何时间区间内只可能被一位读者借阅。输入输入在第一行给出一个正整数N(≤10),随后给出N天的纪录。每...…
-
【一败涂地】L1-006 连续因子 (20分) 题解
题目链接:L1-006 连续因子 (20分)题目一个正整数 N 的因子中可能存在若干连续的数字。例如 630 可以分解为 3×5×6×7,其中 5、6、7 就是 3 个连续的数字。给定任一正整数 N,要求编写程序求出最长连续因子的个数,并输出最小的连续因子序列。输入输入在一行中给出一个正整数 N(1 < N < 2^31)。输出首先在第 1 行输出最长连续因子的个数;然后在第 2 行中按 因子1*因子2*……*因子k 的格式输出最小的连续因子序列,其中因子按递增顺序输出,1 不算在内。样例输入630样例输出35*6*7题意有一点坑 首先就是你求出来的这几个 连续因子 它们的...…
-
【一败涂地】L1-028 判断素数 (10分) 的坑
题目链接:L1-028 判断素数 (10分)题目本题的目标很简单,就是判断一个给定的正整数是否素数。输入输入在第一行给出一个正整数N (≤ 10),随后N行,每行给出一个小于2^31的需要判断的正整数。输出对每个需要判断的正整数,如果它是素数,则在一行中输出Yes,否则输出No。样例输入211111样例输出YesNo解题思路2^31 对应的十进制数是2147483648,是一个十位数,按照正常的思路就是写一个函数,遍历 2到根号n 中间的所有数,如果其中有一个数可以把n整除,那么说明n不是素数。bool is_prime(int n) { for (int i = 2; ...…
-
剪花布条 HDU - 2087 题解
题目链接:剪花布条 HDU - 2087题目一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢?输入输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCII字符有多少个,布条的花纹也有多少种花样。花纹条和小饰条不会超过1000个字符长。如果遇见#字符,则不再进行工作。输出输出能从花纹布中剪出的最多小饰条个数,如果一块都没有,那就老老实实输出0,每个结果之间应换行。样例输入abcde a3aaaaaa aa#样例输出03解题思路利用 string 对...…
-
StandardTemplateLibrary
常用 stl 知识点总结更新: 2022-01-27 更新 bitset 相关,以前觉得用的不多,现在感觉还挺好用=w= 2022-07-05 更新一些 string 相关操作:切片、反转、分割。一些扩展: getline,sscanf,stringstream,控制小数输出,二元组,高级 for 循环请看:STL 进阶 <iomanip>,字符串和数组转换:STL 补充包目录 目录 简介 vector 向量容器 vector 向量容器的声明 迭代器 vector 向量容器的常用方法 vector 向量容器的操作和...…