codeforces 788A Functions again】的更多相关文章

Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about…
…… 原题: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried…
反着求一遍最大连续子序列(前项依赖) #include <bits/stdc++.h> using namespace std; #define LL long long ; int n; LL dp[MAXN]; LL a[MAXN]; LL Cal(int i) { ]); } int main() { scanf("%d", &n); ; i <= n; i++) scanf("%lld", &a[i]); memset(dp…
题意:给定了一个公式,让你找到一对(l,r),求解出公式给定的F值. 当时没有想到,我把(-1)^(i-l)看成(-1)^i,然后思路就完全错了.其实这道题是个简单的dp+最长连续子序列. O(n)求最长连续子序列代码 ll maxx=, sum=, now=; ; i<n; i++) { //数列1-n sum+=dp1[i]; maxx=max(maxx, sum); ) sum=; } 其实我们可以发现,其实正负是交错的,那么我们只要用两个dp(正负相反)的数组来存,再求一次最长连续子序列…
codeforces 407 div1 A题(Functions again) Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, the…
链接 codeforces 题解 结论:\(f_0(n)=2^{n的质因子个数}\)= 根据性质可知\(f_0()\)是一个积性函数 对于\(f_{r+1}()\)化一下式子 对于 \[f_{r+1} = \sum_{d|n}f_r(d)\] \(f_r+1\)可以看做\(f_r()\)和\(g(d)\)的狄利克雷卷积因为\(f_0()\)是积性函数,\(g(d)\)也是积性函数,由卷积性质得\(f_{r+1}()\)也是积性函数,那么\(f_r\)同理 对于\(n\)质因数分解得到: \[n=…
Discription Bash got tired on his journey to become the greatest Pokemon master. So he decides to take a break and play with functions. Bash defines a function f0(n), which denotes the number of ways of factoring n into two factors p and q such that …
[题目链接]:http://codeforces.com/problemset/problem/757/E [题意] 给你q个询问; 每个询问包含r和n; 让你输出f[r][n]; 这里f[0][n]是n分解成两个数u,v的乘积的个数; 这里u和v互质; 而f[r][n]当r>0时,有个递推式; [题解] 那个递推式等价于 即n的所有因子x的f[r][x]的和; 这里需要知道; f[0][n]=2n的不同质因子个数 且容易得到 当a和b互质的时候,f[0][a*b]=f[0][a]*f[0][b…
题目链接: http://codeforces.com/contest/757/problem/E?csrf_token=f6c272cce871728ac1c239c34006ae90 题目: 题解: $f_0(n) = 2^{n的不同质因子的个数}$ $ f_r(n) = \sum_{d|n}f_{r-1}(d)$ $f_0$是积性函数 , $f_r = f_0 * Id^r (1) $也是积性函数 , 所以只需要求$f_r(p^k)$就行了 $f_r(p^k)$与p无关 , $f_0(p^…
[题目链接]:http://codeforces.com/contest/789/problem/C [题意] 看式子. [题解] 考虑最后的答案区间; 如果那个区间是从奇数位置的数字开始的; 那么奇数位上的|a[i+1]-a[i]|的系数(-1)^(i-l)就为1否则为-1 如果那个区间是从偶数位置的数字开始的; 那么偶数位-.就为-1; 按照这个规则我们处理出b[i]=|a[i+1]-a[i]| 然后分两类处理 一种是偶数位的b[i]为正,奇数位的为负; 另一种是奇数位...负....正 然…
题目链接:http://codeforces.com/contest/789/problem/C 题意:就是给出一个公式 然后给出一串数求一个区间使得f(l,r)最大. 这题需要一个小小的处理 可以设数组b[i]和c[i] if i % 2 == 0 b[i]=abs(a[i]-a[i+1]) c[i]=-abs(a[i]-a[i+1]) else b[i]=-abs(a[i]-a[i+1]) c[i]=abs(a[i]-a[i+1]) 然后就是求两个数组的区间和的最大值这个方法就不介绍了 至于…
考虑枚举每个子串开头的位置,然后答案转化成询问这个位置之后 哪个位置的前缀和 - 这位置的前缀和 最大(当然是已经把绝对值和正负的情况处理好了,可以发现按奇偶,这个序列只有两种情况),只需要预处理这两个序列的前缀和,以及这两个前缀和序列的后缀max即可. #include<cstdio> #include<iostream> using namespace std; typedef long long ll; int Abs(int x){ return x<0 ? (-x)…
大意: 定义函数$f_r(n)$, $f_0(n)$为pq=n且gcd(p,q)=1的有序对(p,q)个数. $r \ge 1$时, $f_r(n)=\sum\limits_{uv=n}\frac{f_{r-1}(u)+f_{r-1}(v)}{2}$. $q$组询问, 求$f_r(n)$的值模1e9+7. 显然可以得到$f_0(n)=2^{\omega(n)}$, 是积性函数. 所以$f_r=f_{r-1}*1$也为积性函数, 然后积性函数$dp$即可. 问题就转化为对每个素数$p$, 求$dp…
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给出的01序列相等(比较时如果长度不等各自用0补齐) 题解: 1.我的做法是用Trie数来存储,先将所有数用0补齐成长度为18位,然后就是Trie的操作了. 2.官方题解中更好的做法是,直接将每个数的十进制表示中的奇数改成1,偶数改成0,比如12345,然后把它看成二进制数10101,还原成十进制是2…
D. Moodular Arithmetic Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/problem/D Description As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State Uni…
D. Zigzag time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output The court wizard Zigzag wants to become a famous mathematician. For that, he needs his own theorem, like the Cauchy theorem, or hi…
链接:codeforces.com/contest/8 A 原因:RE,fantasy 的字符串的长度可能大于原字符串. B 题意:上下左右走,可能要避让障碍,问是否存在一个地图使得给定的路径为当前最短路径. 题型:构造,模拟 原因:map不熟,要判两个地方,一是不重复抵达,二是当前点除去前导点旁边的点不能事先经过. 解法:按照上面说的模拟一下就可以,这种方法相对来说效率高,但是代码写得多.可以直接遍历:一个点跟其后面步长大于1的点的距离不能小于1. PS:make_pair的使用方法 map中…
A. Vladik and Courtesy 题面 At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. After that Valera gave Vladik 2 his candies, so that no one thought that he was less generous. Vladik for same…
940C链接:http://codeforces.com/problemset/problem/940/C C. Phone Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output And where the are the phone numbers? You are given a string s consist…
D. Artsem and Saunders 题目连接: http://codeforces.com/contest/765/problem/D Description Artsem has a friend Saunders from University of Chicago. Saunders presented him with the following problem. Let [n] denote the set {1, ..., n}. We will also write f:…
B. Obsession with Robots 题目连接: http://www.codeforces.com/contest/8/problem/B Description The whole world got obsessed with robots,and to keep pace with the progress, great Berland's programmer Draude decided to build his own robot. He was working har…
地址:http://codeforces.com/contest/811/problem/D 题目: D. Vladik and Favorite Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output This is an interactive problem. Vladik has favorite game, in…
A. Neverending competitions time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output There are literally dozens of snooker competitions held each year, and team Jinotega tries to attend them all (f…
地址:http://codeforces.com/contest/765/problem/D 题目: D. Artsem and Saunders time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Artsem has a friend Saunders from University of Chicago. Saunders…
/* CF789C. Functions again http://codeforces.com/contest/789/problem/C 水题 题意:求数组中的连续和的最大值 */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <vector> #include <queue> //#define test u…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State University (BGU) under…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's…
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is…