CodeForces 13A【暴力】】的更多相关文章

题意: 给你的一个十进制数n,计算对于2~n-1进制下的每个位相加和与数n-2的比值. 思路: n是1000,所以直接暴力一发? #include<cstdio> #include<iostream> #include<string.h> #include<algorithm> using namespace std; typedef long long LL; const int N=1e5+10; int solve(int n,int x) { int…
今天,开博客,,,激动,第一次啊 嗯,,先来发水题纪念一下 D1. Magic Powder - 1   This problem is given in two versions that differ only by constraints. If you can solve this problem in large constraints, then you can just write a single solution to the both versions. If you fin…
Adieu l'ami. Koyomi is helping Oshino, an acquaintance of his, to take care of an open space around the abandoned Eikou Cram School building, Oshino's makeshift residence. The space is represented by a rectangular grid of n × m cells, arranged into n…
Rock... Paper! After Karen have found the deterministic winning (losing?) strategy for rock-paper-scissors, her brother, Koyomi, comes up with a new game as a substitute. The game works as follows. A positive integer n is decided first. Both Koyomi a…
It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy to Petya, but he thinks he lacks time to finish them all, so he asks you to help with one.. There is a glob pattern in the statements (a string consis…
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added…
传送门:https://codeforces.com/contest/691/problem/F 题意:给你n个数和q次询问,每次询问问你有多少对ai,aj满足ai*aj>=q[i],注意 a*b 与 b*a是不同的 题解:sum[i]记录的是两个数乘积为i的方法数,然后前缀和记录小于等于乘积为i的方法个数,输出答案就容斥一下,因为n个数最多组成n*(n-1)/2对数,减去小于乘积为q[i]的数后即为乘积大于等于q[i]的方法个数 为什么可以暴力是因为注意到了值域的范围为3e6,调和级数的复杂度…
题目链接 题意: 给定一个字符串,最多更改一个字符,问最多可以有多少个“VK”子串? 思路: 由于数据量很小,不妨尝试暴力写.首先算出不更改任何字符的情况下有多个VK字串,然后尝试每一次更改一个位置的字符,然后暴力算出有多少个VK,取出这些答案中 的最大值,即是答案. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <c…
http://codeforces.com/problemset/problem/548/B Mike and some bears are playing a game just for fun. Mike is the judge. All bears except Mike are standing in an n × m grid, there's exactly one bear in each cell. We denote the bear standing in column n…
大意: 给定两个字符串$a,b$, 每个字符为$0-9$, 每次操作将$a$中相邻两位加$1$或减$1$, 操作后每个数仍要为$0-9$, 求最少操作使$a$变成$b$. 先不考虑范围, 判断是否成立. 然后暴力输出方案即可 #include <iostream> #include <cstdio> #define REP(i,a,n) for(int i=a;i<=n;++i) using namespace std; typedef long long ll; const…
题意: 给你一个区间[l,r],让你从小到大输出k^x,设y=k^x,要保证y在区间[l,r]中 题解: 就算k是最小的2也不需要枚举多少次就到long long的极限了,所以暴力没商量,根本不会TLE 然后就是爆long long处理,比如r特别大,当k^x=<r但是k^(x+1)就爆long long了,这个要注意一下 代码: 1 #include<stdio.h> 2 #include<string.h> 3 #include<iostream> 4 #in…
/* 不要低头,不要放弃,不要气馁,不要慌张. 题意: 给n,m和k,n和m为所给矩阵的高和宽.k是要求最多剩下的湖的数量. 在所给的矩阵中,*代表陆地,.代表水. 湖的定义是一片连续的水(上下左右四个方向),并且水不含边界. 水含边界的情况被成为海. 问最少填多少湖的面积,使得湖的数量减少到k... 思路: 水dfs,记录有多少湖,并且记录每个湖的面积,然后排下序贪心就好. 坑: 做题一定别急一定别急一定别急一定知道自己写的是什么!!!! */ #include<bits/stdc++.h>…
大意: 一天n小时, m分钟, 表以7进制显示, 求表显示数字不同的方案数 注意到小时和分钟部分总长不超过7, 可以直接暴力枚举. 关键要特判0, 0的位数要当做1来处理 #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #include <map> #include <queue> #in…
大意: 给定01矩阵, 求翻转尽量少的数字, 使得所有0或1的连通块为矩形, 若至少要翻转超过k次, 输出-1…
D. New Year Letter time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Many countries have such a New Year or Christmas tradition as writing a letter to Santa including a wish list for presents…
大意: 给定序列, 求划分为一个严格递增子序列和一个严格递减子序列, 可以为空. 跟 125D 类似的一个题, 直接暴力dfs, 用当前序列长度来剪枝, 状态不会太多, 但是会被一些数据卡掉, 特判一下小数据时不剪枝. #include <iostream> #include <sstream> #include <algorithm> #include <cstdio> #include <math.h> #include <set>…
大意: 给定序列, 求划分为两个非空等差序列. 暴搜, 加个记忆化剪枝. #include <iostream> #include <sstream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #include <map> #include <queue> #include <string> #in…
题意:给你一个数组,你可以把数组中的数减少最多k,问数组中的所有数的GCD最大是多少? 思路:容易发现,GCD的上限是数组中最小的那个数,而因为最多可以减少k,及可以凑出来的余数最大是k,那么GCD的下限是k + 1,所以当最小的数小于等于k + 1时,答案是最小的数.如果最小的数大于k + 1,我们从大到小枚举GCD,假设当前枚举的数是x,那么如果一个数在[t * x, t * x + k](t是一个常数)之间,那么就可以被凑出来,我们看一下最后凑出来的数是不是n个就可以了.我们可以用前缀和优…
You are given an array a of size n, and q queries to it. There are queries of two types: 1 li ri — perform a cyclic shift of the segment [li, ri] to the right. That is, for every x such that li ≤ x < ri new value of ax + 1 becomes equal to old value…
题目链接:http://codeforces.com/problemset/problem/724/B 题目大意: 给出N*M矩阵,对于该矩阵有两种操作: (保证,每行输入的数是 1-m 之间的数且不重复) 1.交换两列,对于整个矩阵只能操作一次 2.每行交换两个数. 交换后是否可以使每行都是1-m 数字递增. 解题思路: 1.得到矩阵后先判断,是否每行可以交换两个数可以得到递增的矩阵,如果可以则输出"YES". 2.暴力交换两列,交换两列后,判断每行是否可以交换两个数得到递增的矩阵,…
题目链接: http://www.codeforces.com/contest/666/problem/B 题意: 给你n个城市,m条单向边,求通过最短路径访问四个不同的点能获得的最大距离,答案输出一个满足条件的四个点. 题解: 首先预处理出任意两点的最短距离,用队列优化的spfa跑:O(n*n*logn) 现依次访问四个点:v1,v2,v3,v4 我们可以枚举v2,v3,然后求出v2的最远点v1,v3的最远点v4,为了保证这四个点的不同,直接用最远点会错,v1,v4相同时还要考虑次最远点来替换…
题目链接:http://codeforces.com/problemset/problem/27/E 暴力 //#pragma comment(linker, "/STACK:102400000, 102400000") #include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> #includ…
There is No Alternative 题目连接: http://codeforces.com/gym/100803/attachments Description ICPC (Isles of Coral Park City) consist of several beautiful islands. The citizens requested construction of bridges between islands to resolve inconveniences of u…
Hidden Code 题目连接: http://codeforces.com/gym/100015/attachments Description It's time to put your hacking skills to the test! You've been called upon to help crack enemy codes in the current war on... something or another. Anyway, the point is that yo…
C. Divisibility by Eight Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550/problem/C Description You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leadin…
B. Equivalent Strings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/problem/B Description Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are…
C. Amr and Chemistry Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/558/problem/C Description Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment. Amr has n different type…
E. Holes Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/13/problem/E Description Little Petya likes to play a lot. Most of all he likes to play a game «Holes». This is a game for one person with following rules: There are…
A. Vanya and Table Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/552/problem/A Description Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows are numbered by integers from 1 to 100 from bottom…
B. ZgukistringZ Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/551/problem/B Description Professor GukiZ doesn't accept string as they are. He likes to swap some letters in string to obtain a new one. GukiZ has strings a,…