
基础算法——模拟&思维
Alex_McAvoy
想要成为渔夫的猎手
展开
-
基础算法 —— 模拟&思维
【概述】模拟,是根据实际问题建立模型,模拟实际按程序走一遍,最终求出答案。思维,则是与逻辑思维有关,其需要针对题意、数据范围等抽丝剥茧抽离出有用的信息,从而得出一个结果。对于一般的模拟,直接根据题意编写即可,但是有些模拟会混有别的部分,思维难度较大,且要注意的细节部分很多,大多数模拟题难度不高,只要选择合适的数据结构,注意细节处理,即可顺利写出程序。而对于思维题,容易陷入思维误区,...原创 2018-10-14 01:29:06 · 4641 阅读 · 1 评论 -
Humble Numbers(HDU-1058)
Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the ...原创 2018-03-26 20:42:53 · 311 阅读 · 0 评论 -
小明的账单(信息学奥赛一本通-T1372)
【题目描述】小明在一次聚会中,不慎遗失了自己的钱包,在接下来的日子,面对小明的将是一系列的补卡手续和堆积的账单… 在小明的百般恳求下,老板最终同意延缓账单的支付时间。可老板又提出,必须从目前还没有支付的所有账单中选出面额最大和最小的两张,并把他们付清。还没有支付的账单会被保留到下一天。 请你帮他计算出支付的顺序。【输入】第1行:一个正整数N(N≤15,000),表示小明补办银联卡总共...原创 2018-06-11 20:41:38 · 4117 阅读 · 3 评论 -
Yet Another Walking Robot(CF-1296C)
Problem DescriptionThere 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'...原创 2020-02-06 00:34:01 · 699 阅读 · 0 评论 -
Food Buying(CF-1296B)
Problem DescriptionMishka 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...原创 2020-02-05 22:55:12 · 882 阅读 · 0 评论 -
Array with Odd Sum(CF-1296A)
Problem DescriptionYou 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 (...原创 2020-02-05 22:47:41 · 652 阅读 · 0 评论 -
Collecting Coins(CF-1294A)
Problem DescriptionPolycarp has three sisters: Alice, Barbara, and Cerene. They're collecting coins. Currently, Alice has a coins, Barbara has b coins and Cerene has c coins. Recently Polycarp has ...原创 2020-01-24 14:26:27 · 1241 阅读 · 0 评论 -
JOE is on TV!(CF-1293B)
Problem DescriptionOur dear Cafe's owner, JOE Miller, will soon take part in a new game TV-show "1 vs. n"!The game goes in rounds, where in each round the host asks JOE and his opponents a common...原创 2020-01-21 19:39:33 · 821 阅读 · 0 评论 -
ConneR and the A.R.C. Markland-N (CF-1293A)
Problem DescriptionA.R.C. Markland-N is a tall building with n floors numbered from 1 to n. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime fo...原创 2020-01-20 21:59:27 · 1542 阅读 · 0 评论 -
Quailty and CCPC(HDU-6666)
Problem DescriptionConsidering the overall difficulty of other problems, we invite Quailty to propose an easy problem for this contest.Quailty accidentally won both gold medal and silver medal in...原创 2019-10-13 18:08:41 · 434 阅读 · 0 评论 -
Acesrc and Good Numbers(HDU-6659)
Problem DescriptionAcesrc is a famous mathematician at Nanjing University second to none. Playing with interesting numbers is his favorite. Today, he finds a manuscript when cleaning his room, whic...原创 2019-10-13 15:37:18 · 381 阅读 · 0 评论 -
Lefthanders and Righthanders(CF-234A)
Problem DescriptionOne fine October day a mathematics teacher Vasily Petrov went to a class and saw there n pupils who sat at the desks, two people at each desk. Vasily quickly realized that number...原创 2019-07-31 09:13:39 · 375 阅读 · 0 评论 -
Connected Component on a Chessboard(CF-1196E)
Problem DescriptionYou are given two integers bb and ww. You have a chessboard of size 109×109109×109 with the top left cell at (1;1)(1;1), the cell (1;1) is painted white.Your task is to find a ...原创 2019-07-25 19:22:20 · 596 阅读 · 2 评论 -
Boring Partition(CF-239D)
Problem DescriptionThis problem is the most boring one you've ever seen.Given a sequence of integers a1, a2, ..., an and a non-negative integer h, our goal is to partition the sequence into two s...原创 2019-08-03 09:13:20 · 236 阅读 · 0 评论 -
Cinema(CF-234D)
Problem DescriptionOverall there are m actors in Berland. Each actor has a personal identifier — an integer from 1 to m (distinct actors have distinct identifiers). Vasya likes to watch Berland mov...原创 2019-07-31 10:05:28 · 276 阅读 · 0 评论 -
Three Piles of Candies(CF-1196A)
Problem DescriptionAlice and Bob have received three big piles of candies as a gift. Now they want to divide these candies as fair as possible. To do this, Alice takes one pile of candies, then Bob...原创 2019-07-25 10:15:41 · 561 阅读 · 0 评论 -
Chocolate Bar(AtCoder-2565)
Problem DescriptionThere is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of bloc...原创 2019-07-18 16:15:08 · 688 阅读 · 0 评论 -
Bugged(AtCoder-2579)
Problem DescriptionYou are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is si. Your answer to each question will be jud...原创 2019-07-18 16:14:25 · 400 阅读 · 0 评论 -
Traveling(AtCoder-3875)
Problem DescriptionAtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0,0) at time 0, then for each i between 1 and N (inclusive), he will visi...原创 2019-07-15 18:20:20 · 519 阅读 · 0 评论 -
Non-decreasing(AtCoder-3720)
Problem DescriptionSnuke has an integer sequence, a, of length N. The i-th element of a (1-indexed) is ai.He can perform the following operation any number of times:Operation: Choose integers x...原创 2019-07-01 19:39:22 · 329 阅读 · 0 评论 -
高橋君と見えざる手 / An Invisible Hand(AtCoder-2147)
Problem DescriptionThere are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples.Takahashi w...原创 2019-05-22 22:33:04 · 416 阅读 · 0 评论 -
Scc Puzzle(AtCoder-2333)
Problem DescriptionSnuke loves puzzles.Today, he is working on a puzzle usingS- andc-shaped pieces. In this puzzle, you can combine twoc-shaped pieces into oneS-shaped piece, as shown in the ...原创 2019-05-30 16:24:29 · 619 阅读 · 0 评论 -
Menagerie(AtCoder-2234)
Problem DescriptionSnuke, who loves animals, built a zoo.There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i(2≤i≤N−1) is a...原创 2019-05-30 18:07:28 · 1901 阅读 · 0 评论 -
Sequence(AtCoder-2399)
Problem DescriptionYou are given an integer sequence of length N. The i-th term in the sequence is ai. In one operation, you can select a term and either increment or decrement it by one.At least...原创 2019-06-06 20:13:18 · 647 阅读 · 0 评论 -
Sentou(AtCoder-2555)
Problem DescriptionIn a public bath, there is a shower which emits water for T seconds when the switch is pushed.If the switch is pushed when the shower is already emitting water, from that momen...原创 2019-06-06 20:36:47 · 622 阅读 · 0 评论 -
Vertical Histogram(POJ-2136)
Problem DescriptionWrite a program to read four lines of upper case (i.e., all CAPITAL LETTERS) text input (no more than 72 characters per line) from the input file and print a vertical histogram t...原创 2019-06-01 22:33:33 · 251 阅读 · 0 评论 -
Decrease (Contestant ver.)(AtCoder-2661)
Problem DescriptionWe have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence become...原创 2019-06-15 16:02:17 · 333 阅读 · 0 评论 -
Decrease (Judge ver.)(AtCoder-2662)
Problem DescriptionWe have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence become...原创 2019-06-15 16:42:26 · 472 阅读 · 0 评论 -
Grid Coloring(AtCoder-2687)
Problem DescriptionWe have a grid with H rows and W columns of squares. Snuke is painting these squares in colors 1, 2, …, N. Here, the following conditions should be satisfied:For each i (1≤i≤N)...原创 2019-06-16 19:39:53 · 459 阅读 · 0 评论 -
Champions' League(CF-234E)
Problem DescriptionIn the autumn of this year, two Russian teams came into the group stage of the most prestigious football club competition in the world — the UEFA Champions League. Now, these tea...原创 2019-07-31 10:38:49 · 321 阅读 · 0 评论 -
The table(CF-226D)
Problem DescriptionHarry Potter has a difficult homework. Given a rectangular table, consisting of n × m cells. Each cell of the table contains the integer. Harry knows how to use two spells: the f...原创 2019-07-26 13:40:48 · 243 阅读 · 0 评论 -
Final Exam(HDU-6651)
Problem DescriptionFinal Exam is coming! Cuber QQ has now one night to prepare for tomorrow's exam.The exam will be a exam of problems sharing altogether m points. Cuber QQ doesn't know about the...原创 2019-10-11 16:31:20 · 301 阅读 · 0 评论 -
Divide the Stones(HDU-6616)
Problem DescriptionThere are n stones numbered from 1 to n.The weight of the i-th stone is i kilograms. We divide the stones into k groups.Each group consists of exactly stones.We define the wei...原创 2019-10-07 14:10:31 · 281 阅读 · 0 评论 -
Just an Old Puzzle(HDU-6620)
Problem DescriptionYou are given a 4 × 4 grid, which consists of 15 number cells and an empty cell.All numbers are unique and ranged from 1 to 15.In this board, the cells which are adjacent with ...原创 2019-10-07 14:16:22 · 248 阅读 · 0 评论 -
Little Elephant and Shifts(CF-220C)
Problem DescriptionThe Little Elephant has two permutations a and b of length n, consisting of numbers from 1 to n, inclusive. Let's denote the i-th (1 ≤ i ≤ n) element of the permutation a as ai, ...原创 2019-07-27 21:05:09 · 290 阅读 · 0 评论 -
Walking Between Houses(CF-1015D)
Problem DescriptionThere are n houses in a row. They are numbered from 1to nn in order from left to right. Initially you are in the house 1.You have to perform kk moves to other house. In one mo...原创 2018-08-06 11:14:08 · 380 阅读 · 0 评论 -
Points and Powers of Two(CF-988D)
Problem DescriptionThere are n distinct points on a coordinate line, the coordinate of i-th point equals to xi. Choose a subset of the given set of points such that the distance between each pair o...原创 2018-08-07 19:36:47 · 455 阅读 · 0 评论 -
Just Skip The Problem(HDU-6600)
Problem DescriptionY_UME has just found a numberxin his right pocket. The number is a non-negative integer ranging from0to2n−1inclusively. You want to know the exact value of this number. Y_U...原创 2019-09-23 22:13:22 · 254 阅读 · 0 评论 -
Vacation(HDU-6581)
Problem DescriptionTom and Jerry are going on a vacation. They are now driving on a one-way road and several cars are in front of them. To be more specific, there arencars in front of them. Thei...原创 2019-09-22 22:27:10 · 313 阅读 · 0 评论 -
Buy Watermelon(2019 ACM-ICPC 徐州赛区网络赛 C)
Problem DescriptionThe hot summer came so quickly that Xiaoming and Xiaohong decided to buy a big and sweet watermelon. But they are two very strange people. They are even-numbered enthusiasts. The...原创 2019-09-10 20:05:28 · 367 阅读 · 0 评论