Codeforces 354C 暴力 数论】的更多相关文章

题意:给你一个数组,你可以把数组中的数减少最多k,问数组中的所有数的GCD最大是多少? 思路:容易发现,GCD的上限是数组中最小的那个数,而因为最多可以减少k,及可以凑出来的余数最大是k,那么GCD的下限是k + 1,所以当最小的数小于等于k + 1时,答案是最小的数.如果最小的数大于k + 1,我们从大到小枚举GCD,假设当前枚举的数是x,那么如果一个数在[t * x, t * x + k](t是一个常数)之间,那么就可以被凑出来,我们看一下最后凑出来的数是不是n个就可以了.我们可以用前缀和优…
Vasya and Beautiful Arrays CodeForces - 354C Vasya's got a birthday coming up and his mom decided to give him an array of positive integers a of length n. Vasya thinks that an array's beauty is the greatest common divisor of all its elements. His mom…
今天,开博客,,,激动,第一次啊 嗯,,先来发水题纪念一下 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…
Maximal GCD 题目链接:http://codeforces.com/problemset/problem/735/D ——每天在线,欢迎留言谈论. 题目大意: 给你一个n(2≤n≤2e9) 代表一个人的收入. 他需要交税,规则:交税金额为n的最大公约数(本身不算) 他想通过把钱分成几份,然后分别交税,达到交税最少. 知识点: 哥德巴赫猜想:①如果一个数为偶数,那么可以拆成两个质数相加 ②如果一个奇数 (n-2)为质数那么他也可以拆成两个质数相加(2+(n-2)) ③其他的奇数 可以拆成…
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…