暴力枚举
暴力枚举刷题分类
Suprit
先选择一种经历,经历再造就一个人
展开
-
【题解】codeforce1237 B. Balanced Tunnel⭐⭐【双指针】
codeforce1237 B. Balanced Tunnel⭐⭐ Consider a tunnel on a one-way road. During a particular day, n cars numbered from 1 to n entered and exited the tunnel exactly once. All the cars passed through the...原创 2019-10-17 11:09:41 · 510 阅读 · 0 评论 -
codeforce 1133C. Balanced Team(尺取)
codeforce 1133C. Balanced Team You are a coach at your local university. There are n students under your supervision, the programming skill of the i-th student is ai. You have to create a team for a ...原创 2019-03-10 16:29:07 · 491 阅读 · 0 评论 -
Minesweeper UVA - 10189 (枚举+模拟)
Minesweeper UVA - 10189 Have you ever played Minesweeper? It’s a cute little game which comes within a certain Operating System which name we can’t really remember. Well, the goal of the game is to ...原创 2019-03-17 22:08:13 · 375 阅读 · 0 评论 -
Restoring Painting CodeForces - 675B (枚举次数)
Restoring Painting CodeForces - 675B Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn’t want to be fired, so he ...原创 2019-04-07 21:54:24 · 263 阅读 · 0 评论 -
C. Gourmet Cat (枚举 规律)
C. Gourmet Cat (枚举 规律) Polycarp has a cat and his cat is a real gourmet! Dependent on a day of the week he eats certain type of food: on Mondays, Thursdays and Sundays he eats fish food; on Tuesdays ...原创 2019-04-18 18:11:58 · 820 阅读 · 0 评论 -
Make Them Equal CodeForces - 1154B (枚举)
Make Them Equal CodeForces - 1154B You are given a sequence a1,a2,…,an consisting of n integers. You can choose any non-negative integer D (i.e. D≥0), and for each ai you can: add D (only once), i. ...原创 2019-04-18 18:21:15 · 394 阅读 · 0 评论 -
【题解】1927: 机器设备⭐⭐⭐ 【搜索】
【题解】1927: 机器设备⭐⭐⭐ 【搜索】 Alpha 公司设计出一种节能的机器设备。它的内部结构是由 N 个齿轮组成。整个机器设备有 一个驱动齿轮,当启动它时,它立即按 10,000 圈/小时转速顺时针转动,然后它又带动与它相切 的齿轮反方向,即逆时针转动。齿轮之间互相作用,每个齿轮都可能驱动着多个齿轮,最终带动 一个工作齿轮完成相应的任务 。 在这套设备中,记录了每个齿轮的圆心坐标和齿轮半径...原创 2019-05-14 17:53:33 · 224 阅读 · 0 评论 -
【题解】B. Lost Numbers⭐⭐【CF交互题 暴力】
B. Lost Numbers This is an interactive problem. Remember to flush your output while communicating with the testing program. You may use fflush(stdout) in C++, system.out.flush() in Java, stdout.flush(...原创 2019-05-17 11:22:47 · 536 阅读 · 0 评论 -
【题解】B. Plus from Picture⭐⭐ 【枚举】
B. Plus from Picture You have a given picture with size w×h. Determine if the given picture has a single “+” shape or not. A “+” shape is described below: A “+” shape has one center nonempty cell. The...原创 2019-06-12 21:44:53 · 580 阅读 · 0 评论 -
【题解】银联挑战赛2A 码队GO⭐⭐⭐ 【二维前缀和】
银联挑战赛2A 码队GO 码队最近开发了一款基于虚拟现实的「码队GO」寻宝手游,他打算在银联唐镇园区里测试这个游戏。这个游戏规定,必须选择一个正方形的空旷区域来寻宝。但银联唐镇园区里有很多地方都会有各种各样的障碍物,码队想要请你帮忙,帮他找到一个最佳的游戏测试区域。 问题可以看成一个 n \times mn×m 的方格,共有 nn 行 mm 列,每个小方格由 * ∗ 和 . . 表示。( * ∗ ...原创 2019-07-24 09:04:58 · 284 阅读 · 0 评论 -
【题解】codeforce1217 C. The Number Of Good Substrings⭐⭐ 【思维 枚举】
codeforce1217 C. The Number Of Good Substrings You are given a binary string s (recall that a string is binary if each character is either 0 or 1). Let f(t) be the decimal representation of integer t ...原创 2019-09-09 21:47:25 · 447 阅读 · 0 评论 -
L1-006 连续因子 (枚举 好题)
L1-006 连续因子 一个正整数 N 的因子中可能存在若干连续的数字。例如 630 可以分解为 3×5×6×7,其中 5、6、7 就是 3 个连续的数字。给定任一正整数 N,要求编写程序求出最长连续因子的个数,并输出最小的连续因子序列。 Input 输入在一行中给出一个正整数 N(1<N<231)。 Output 首先在第 1 行输出最长连续因子的个数;然后在第 2 行中按 因...原创 2019-03-04 09:21:36 · 5393 阅读 · 0 评论 -
Subsequence POJ - 3061 (二分 尺取)
题意: 给出n个整数a[i], 求总和不小于S的连续子序列的最小长度, 不存在输出0 题解: 这道题可用二分, 也可用尺取来做(尺取的经典题目), 首先简单说一下二分 这道题用二分法写的话也有一个比较巧妙的地方, 就是预处理: 定义sum[i]表示∑0iai\sum_0^iai∑0iai 序列a[i-j]和即为sum[j]-sum[i] 判定条件check函数意为: 以t结尾时不小于S的序列...原创 2019-01-30 17:42:53 · 237 阅读 · 0 评论 -
Sum of Consecutive Prime Numbers POJ - 2739(尺取)
简单的尺取题, 拿来练手咯, 顺便复习一波欧拉筛 #include &lt;cstdio&gt; #include &lt;iostream&gt; #include &lt;algorithm&gt; #include &lt;cstring&gt; using namespace std; #define ms(x, n) memset(x,n,sizeof(x)); type原创 2019-02-02 22:48:50 · 218 阅读 · 0 评论 -
Poj百练 2810:完美立方 (分类:枚举)
这是一道经典的枚举优化问题,体现了前缀和预处理思想。 经过总结,枚举的优惠大致有以下几点: 1.通过数学知识,自然判断等人为的缩小某些一定不会发生的范围 2.找出题中的自然联系,如生理周期问题每找到一个周期后迭代周期之积即可 3.前缀和预处理,对于枚举中多次使用的数据提前计算出来,如完美立方问题对立方的预处理 //poj2180完美立方 #include <iostream>...原创 2018-08-07 14:34:54 · 495 阅读 · 0 评论 -
拨钟问题 OpenJ_Bailian - 2814 (枚举)
https://vjudge.net/problem/OpenJ_Bailian-2814 这是一道和画家问题,熄灯问题极为相似的题目。 共同特性:操作对环境的改变是无序的,每个操作都会影响到周围的状态。 同时每一种操作都有周期性限制,也即最多需要几次操作,多于这个次数产生相等效果的循环。 这类题也有一个共同的解决思路:确定一个小的枚举方案,这个枚举方案产生的结果一定会促使下面的操作。例如...原创 2018-09-05 11:37:46 · 482 阅读 · 0 评论 -
001:特殊密码锁(贪心)
http://cxsjsxmooc.openjudge.cn/2018t2winterw1/001/ 这道题不难,可以枚举来写,每个锁两种状态一共30个锁2^30的复杂度可能不会超,在此提供另外一种贪心的思路。 对于第一个锁,我们枚举(好吧算不上枚举)开或不开两种情况。如果第一个锁不为目标状态,那么只有第二个锁才能关掉它。。。依次类推,如果第i个锁不为目标状态,那么只有第i+1个锁才能关掉它 ...原创 2018-09-05 19:54:22 · 734 阅读 · 1 评论 -
Fractions Again?! UVA - 10976 (枚举)
按照刘汝佳书上的思路来,y >= x,可以转换为y <= 2k。因为k的范围足足有10000,精度问题很严重,所以此题中绝对不能出现除法。那就只能通过通分来把除法转化为乘法 :ky / y-k 。可以预见,当k为正整数的时候符合条件即可。 #include<bits/stdc++.h> using namespace std; const int maxn = 100...原创 2018-09-16 11:22:57 · 192 阅读 · 0 评论 -
Division UVA - 725 (枚举)
虽然是简单枚举。。但其实题中需要考虑的东西还蛮多的。前几位为0的情况用%05d补齐就行,然后计算0-9各个数的输出次数即可 #include<bits/stdc++.h> using namespace std; int cnt[15]; //0-9每个数的出现次数 bool judge(int c, int d) { if(d > 98765) return ...原创 2018-09-14 13:41:13 · 220 阅读 · 0 评论 -
Fliptile POJ - 3279 (局部枚举 + 状态压缩)
https://vjudge.net/problem/POJ-3279 参考博客: https://blog.csdn.net/loy_184548/article/details/50949972 这道题目在vj上的kuangbin比赛中被归类到了搜索, 其实它还算不上搜素, 是一道比较基础的枚举题目,和熄灯问题, 画家问题,拨钟问题是一类题, 如果单纯用爆搜或者枚举来考虑的话可能会超时,复...原创 2018-10-10 14:58:41 · 1709 阅读 · 1 评论 -
PAT 1007 素数对猜想 (枚举, 难度1) - 详细题解
筛法求素数 + 枚举即可 #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <vector> #include <queue> #include &原创 2018-11-24 11:25:24 · 294 阅读 · 0 评论 -
PAT 1083 是否存在相等的差 (枚举 难度2) - 详细题解
数组开大点, 枚举模拟即可 #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <stdlib.h> #include <vector> #inclu原创 2018-12-04 22:21:51 · 207 阅读 · 0 评论 -
CodeForce1108C. Nice Garland (暴力+思维)
题意: 给出一个包含RGB三种颜色的序列, 要求改动最少的颜色, 使得所有相同元素之间的距离都是3的倍数 思路:仔细思考题意, 我们可以发现, 要想使得满足nice的条件, 只有两种可能 元素数量<3, 且互不相等 元素数量>=3, 则只能是 {“GRB”,“GBR”,“RGB”,“RBG”,“BGR”,“BRG”}, 种的一种重复出现 由此我们可以直接枚举这6种排列方式, 找出...原创 2019-01-26 11:34:01 · 611 阅读 · 0 评论 -
Jessica's Reading Problem POJ - 3320 (尺取)
题意: 给出n个用知识点(整数)的页码, 求得能够复习所有出现的知识点的最小连续页码数 题解: 毫无疑问这道题目符合尺取的不断右移, 左移的特征 如果还能发现未复习的点或复习点数量小于总数则右移 如果遍历完依然没有复习完则退出循环 否则试图左移 #include <cstdio> #include <iostream> #include <algorithm&g...原创 2019-02-01 17:29:10 · 310 阅读 · 0 评论 -
Poj百练 4148:生理周期 (分类:枚举)
经典的枚举优化问题 //poj4148生理周期 #include <iostream> #include<cstdio> using namespace std; int main() { int p, e, i, d, index = 1; scanf("%d%d%d%d",&p,&e,&i,&d); whil...原创 2018-08-07 13:55:53 · 1021 阅读 · 1 评论