搜索——暴力搜索
Alex_McAvoy
想要成为渔夫的猎手
展开
-
搜索 —— 暴力搜索
【暴力搜索】暴力搜索,就是将所有情况都举出,并判断其是否符合题目条件。其基本方法是分析题意后,找到一个合适的维度列举每一个元素,以完成题目。一般主流的 OJ 中,1000ms 的时间限制下可以运行操作数为 10^7 以内的运算(10^6 以内较保险),所以在采用枚举方法之前最好看一下数据范围,确保整个程序的执行操作数不会超过 10^6~10^7 量级。在编程实现上,暴力枚举需要两个条件...原创 2018-10-16 11:24:02 · 4312 阅读 · 0 评论 -
最小函数值(信息学奥赛一本通-T1370)
【题目描述】有n个函数,分别为F1,F2,...,Fn。定义Fi(x)=Aix2+Bix+Ci(x∈N∗)。给定这些Ai、Bi和Ci,请求出所有函数的所有函数值中最小的m个(如有重复的要输出多个)。【输入】第一行输入两个正整数n和m。以下n行每行三个正整数,其中第ii行的三个数分别位Ai、Bi和Ci。输入数据保证Ai≤10,Bi≤100,Ci≤10000。【输出】将这n个...原创 2018-06-11 20:44:55 · 2597 阅读 · 1 评论 -
Three Parts of the Array(CF-1006C)
Problem DescriptionYou are given an array d1,d2,…,dn consisting of nn integer numbers.Your task is to split this array into three parts (some of which may be empty) in such a way that each elemen...原创 2018-08-06 09:07:09 · 313 阅读 · 0 评论 -
和为给定数(信息学奥赛一本通-T1244)
【题目描述】给出若干个整数,询问其中是否有一对数的和等于给定的数。【输入】第一行是整数n(0 < n ≤ 100,000),表示有n个整数。第二行是n个整数。整数的范围是在0到108之间。第三行是一个整数m(0≤m≤230),表示需要得到的和。【输出】若存在和为m的数对,输出两个整数,小的在前,大的在后,中间用单个空格隔开。若有多个数对满足条件,选择数对中较小的...原创 2018-05-18 17:09:01 · 5624 阅读 · 5 评论 -
ISBN(POJ-2190)
Problem DescriptionFarmer John's cows enjoy reading books, and FJ has discovered that his cows produce more milk when they read books of a somewhat intellectual nature. He decides to update the bar...原创 2019-06-01 22:28:50 · 283 阅读 · 0 评论 -
くんと選挙速報 / AtCoDeer and Election Report (AtCoder-2140)
Problem DescriptionAtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current ...原创 2019-05-22 20:35:59 · 318 阅读 · 0 评论 -
小b删列(51Nod-2523)
题目小b有一个n*m的矩阵A,矩阵的每个元素为一个字符,现在她希望删除其中的一些列,使得剩下的列在每一行形成的字符串的字典序不降。即对于第i行,将剩下的列上的字符顺序拼接,形成一个字符串,记作a[i]。要求a[i]<=a[i+1](i=1..n-1)。请问小b最少要删多少列。如A = {"abcdef", "uvwxyz"},删除的列为第1,3,4列,删除后 A 为{"be...原创 2019-05-13 15:58:44 · 300 阅读 · 2 评论 -
重排列(51Nod-2513)
题目有两个长度为n的序列A,B,你需要重排列A,使得满足A[i]>B[i]的i的数目尽量大。只需输出这个最大个数即可。输入第一行输入一个正整数n;第二、三行分别输出n个非负整数,表示A、B中的元素,以空格隔开;其中1≤n≤10000,0≤A[i],B[i]≤10^9。输出输出一行一个数,表示最大个数输入样例42 7 11 151 10 4 11输...原创 2019-05-13 15:36:16 · 344 阅读 · 0 评论 -
最长高地(51Nod-2509)
题目小b有一个长度为n的数组A。小b认为,如果A的一个区间[l,r]满足r-l>=2,且存在l<p<r使得A[l]<A[l+1]<... <A[p]>A[p+1]>...>A[r],则[l,r]为一个高地。求A中的最长高地的长度。输入第一行输入一个非负整数n,表示A数组长度;第二行输入n个数,表示A数组的元素,以空格隔开...原创 2019-05-13 14:48:57 · 273 阅读 · 0 评论 -
Derangement(AtCoder-3525)
Problem DescriptionYou are given a permutation p1,p2,…,pN consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero):Operation: Swap two adjacent elements...原创 2019-06-21 13:53:23 · 335 阅读 · 0 评论 -
Sugar Water(AtCoder-3534)
Problem DescriptionSnuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perfor...原创 2019-06-21 18:39:20 · 401 阅读 · 0 评论 -
Snuke Festival(AtCoder-3620)
Problem DescriptionThe season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three part...原创 2019-06-22 11:36:37 · 358 阅读 · 0 评论 -
最多分成多少块(51Nod-2502)
题目小b有个长度为n的数组a,她想将这个数组排序。然而小b很懒,她觉得对整个数组排序太累了,因此她请你将a分成一些块,使得她只需要对每一块分别排序,就能将整个数组排序。请问你最多能把a分成多少块。保证a为0...n-1的一个排列。输入第一行一个数n;第二行n个数表示a[i],以空格隔开。n<=10输出输出一个数表示划分块的数量输入样例54 3 ...原创 2019-07-23 16:07:03 · 984 阅读 · 0 评论 -
Hydra(CF-244D)
Problem DescriptionOne day Petya got a birthday present from his mom: a book called "The Legends and Myths of Graph Theory". From this book Petya learned about a hydra graph.A non-oriented graph ...原创 2019-08-07 22:04:53 · 245 阅读 · 0 评论 -
Physics Practical(CF-253B)
Problem DescriptionOne day Vasya was on a physics practical, performing the task on measuring the capacitance. He followed the teacher's advice and did as much as n measurements, and recorded the r...原创 2019-08-14 14:23:09 · 251 阅读 · 0 评论 -
Text Editor(CF-253C)
Problem DescriptionVasya is pressing the keys on the keyboard reluctantly, squeezing out his ideas on the classical epos depicted in Homer's Odysseus... How can he explain to his literature teacher...原创 2019-08-14 14:38:58 · 376 阅读 · 0 评论 -
Matryoshka Dolls (Gym-102267C)
Problem DescriptionMatryoshka Dolls are Russia's most popular souvenirs. They are sets of wooden figurines of decreasing size placed one inside another, though they have the same exact shape.Our ...原创 2019-08-21 10:19:41 · 1156 阅读 · 0 评论 -
Playing with Permutations(CF-252D)
Problem DescriptionLittle Petya likes permutations a lot. Recently his mom has presented him permutation q1, q2, ..., qn of length n.A permutation a of length n is a sequence of integers a1, a2, ...原创 2019-08-12 17:13:19 · 255 阅读 · 0 评论 -
Banana(2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 A)
Problem DescriptionBananas are the favoured food of monkeys.In the forest, there is a Banana Company that provides bananas from different places.The company has two lists.The first list recor...原创 2019-08-27 09:10:52 · 21644 阅读 · 0 评论 -
いっしょ / Be Together(AtCoder-2019)
Problem DescriptionEvi has N integers a1,a2,..,aN. His objective is to have N equal integers by transforming some of them.He may transform each integer at most once. Transforming an integer x int...原创 2019-05-19 13:12:03 · 379 阅读 · 0 评论 -
后面第一个大于(51Nod-2500)
题目小b有一个长度为n的序列t,现在她对于每个i,求最小的正数j满足i+j≤n且ti+j>ti,输出j,如果不存在这样的j,则输出0。样例解释:对于i=1,t2>t1,所以最小的j=1;对于i=7,不存在这样的j,所以输出0。输入第一行输入一个数n;第二行输入n个数t1-tn,以空格隔开;其中1≤n≤30000,对于任意ti满足30≤ti≤100.输出...原创 2019-04-29 20:13:03 · 340 阅读 · 0 评论 -
权势二进制(51Nod-1413)
题目一个十进制整数被叫做权势二进制,当他的十进制表示的时候只由0或1组成。例如0,1,101,110011都是权势二进制而2,12,900不是。当给定一个n的时候,计算一下最少要多少个权势二进制相加才能得到n。输入单组测试数据。第一行给出一个整数n (1<=n<=1,000,000)输出输出答案占一行。输入样例9输出样例9思路:分解每一...原创 2019-04-25 09:21:58 · 284 阅读 · 0 评论 -
Sonya and Matrix(CF-1004D)
Problem DescriptionSince Sonya has just learned the basics of matrices, she decided to play with them a little bit.Sonya imagined a new type of matrices that she called rhombic matrices. These ma...原创 2018-08-26 18:48:19 · 551 阅读 · 0 评论 -
连续自然数和(洛谷-P1147)
题目描述对一个给定的自然数M,求出所有的连续的自然数段,这些连续的自然数段中的全部数之和为M。例子: 1998+1999+2000+2001+2002=10000,所以从1998到 2002的一个自然数段为 M=10000的一个解。输入输出格式输入格式:包含一个整数的单独一行给出M的值(10≤M≤2,000,000)。输出格式:每行两个自然数,给...原创 2018-08-16 18:45:34 · 1797 阅读 · 0 评论 -
烤鸡(洛谷-P2089)
题目描述猪猪Hanke特别喜欢吃烤鸡(本是同畜牲,相煎何太急!)Hanke吃鸡很特别,为什么特别呢?因为他有10种配料(芥末、孜然等),每种配料可以放1—3克,任意烤鸡的美味程度为所有配料质量之和现在,Hanke想要知道,如果给你一个美味程度,请输出这10种配料的所有搭配方案输入输出格式输入格式:一行,n<=5000输出格式:第一行,方案总数第二行至结束,1...原创 2018-02-28 17:13:37 · 1259 阅读 · 0 评论 -
Elections(CF-1020C)
Problem DescriptionAs you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the followi...原创 2018-08-14 16:21:48 · 600 阅读 · 0 评论 -
Mishka and Contest(CF-999A)
Problem DescriptionMishka started participating in a programming contest. There are nn problems in the contest. Mishka's problem-solving skill is equal to kk.Mishka arranges all problems from the...原创 2018-08-07 18:46:31 · 398 阅读 · 0 评论 -
Letters(CF-978C)
Problem DescriptionThere are nn dormitories in Berland State University, they are numbered with integers from 1 to n. Each dormitory consists of rooms, there are aiai rooms in i-th dormitory. The r...原创 2018-08-09 17:32:49 · 413 阅读 · 0 评论 -
File Name(CF-978B)
Problem DescriptionYou can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file ...原创 2018-08-09 17:27:52 · 409 阅读 · 0 评论 -
Remove Duplicates(CF-978A)
Problem DescriptionPetya has an array aa consisting of n integers. He wants to remove duplicate (equal) elements.Petya wants to leave only the rightmost entry (occurrence) for each element of the...原创 2018-08-09 17:23:21 · 325 阅读 · 0 评论 -
Relatively Prime Graph(CF-1009D)
Problem DescriptionLet's call an undirected graph G=(V,E) relatively prime if and only if for each edge (v,u)∈E(v,u),GCD(v,u)=1 (the greatest common divisor of vand uis 1). If there is no edge be...原创 2018-08-23 20:56:12 · 319 阅读 · 0 评论 -
Close Encounter(POJ-3039)
Problem DescriptionLacking even a fifth grade education, the cows are having trouble with a fraction problem from their textbook. Please help them. The problem is simple: Given a properly reduced f...原创 2018-07-25 21:03:14 · 300 阅读 · 0 评论 -
Sequence in the Pocket(ZOJ-4104)
Problem DescriptionDreamGrid has just found an integer sequence a1,a2,...,anin his right pocket. As DreamGrid is bored, he decides to play with the sequence. He can perform the following operation...原创 2019-04-27 19:12:46 · 741 阅读 · 0 评论 -
不降的数字(51Nod-2499)
题目小b有一个非负整数 N,她想请你找出 ≤N 的最大整数x,满足x各个位数上的数字是不降的。也就是说,设x的十进制表示为 a1,a2,…,am,则对于任意 1≤i<m,ai≤ai+1。输入输入一个非负整数N。0≤N≤10^9输出输出一个整数,表示答案输入样例332输出样例299思路:从 n 开始枚举,每次的 i 进行分解数位,满足不降即可源...原创 2019-04-26 22:12:32 · 544 阅读 · 0 评论 -
数三角形(51Nod-2497)
题目小b有一个仅包含非负整数的数组a,她想知道有多少个三元组(i,j,k),满足i<j<k且a[i],a[j],a[k]可能作为某个三角形的三条边的边长。输入第一行输入一个正整数n,表示数组a中元素个数;第二行n个非负整数,表示a中元素,以空格隔开;其中0<n≤1000,a中任意元素a[i]满足0≤a[i]≤1000。输出输出一个数,表示满足题意的三元组个数...原创 2019-04-26 20:44:29 · 826 阅读 · 0 评论 -
Intense Heat(CF-1003C)
Problem DescriptionThe heat during the last few days has been really intense. Scientists from all over the Berland study how the temperatures and weather change, and they claim that this summer is ...原创 2018-08-05 20:11:44 · 277 阅读 · 0 评论 -
Purification(CF-330C)
Problem DescriptionYou are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an n × n grid...原创 2019-02-11 13:48:21 · 1165 阅读 · 0 评论 -
Chip Factory(HDU-5536)
Problem DescriptionJohn is a manager of a CPU chip factory, the factory produces lots of chips everyday. To manage large amounts of products, every processor has a serial number. More specifically,...原创 2019-01-18 16:04:39 · 283 阅读 · 0 评论 -
斯诺登的密码(洛谷-P1603)
题目描述2013年X月X日,俄罗斯办理了斯诺登的护照,于是他混迹于一架开往委内瑞拉的飞机。但是,这件事情太不周密了,因为FBI的间谍早已获悉他的具体位置——但这不是最重要的——最重要的是如果要去委内瑞拉,那么就要经过古巴,而经过古巴的路在美国的掌控之中。丧心病狂的奥巴马迫降斯诺登的飞机,搜查时却发现,斯诺登杳无踪迹。但是,在据说是斯诺登的座位上,发现了一张纸条。纸条由纯英文构成:Obama ...原创 2018-04-11 23:36:35 · 1423 阅读 · 2 评论 -
Diverse Substring(CF-1037A)
Problem DescriptionYou are given a string s, consisting of nn lowercase Latin letters.A substring of string s is a continuous segment of letters from ss. For example, "defor" is a substring of "c...原创 2018-10-31 20:45:10 · 840 阅读 · 0 评论