【CodeForces 616D】Longest k-Good Segment】的更多相关文章

题意 n个数里,找到最长的一个连续序列使里面最多k个不同的数. 分析 尺取法,每次R++,如果第R个数未出现过,那么不同的数+1,然后这个数的出现次数+1,如果不同的数大于k了,那就要去掉第L个数,直到不同的数为k,然后更新答案. 代码 #include<cstdio> #define ll long long #define N 500005 int n,k; int a[500005],num[1000005]; int l,r; int s,ansl,ansr; int main() {…
[题目链接] 点击打开链接 [算法] 设取的所有数都是k的约数,则这些数的lcm必然不大于k. 对于[1, m]中的每个数,统计a中有多少个数是它的约数即可. [代码] #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll MAXN = 1e6; ll i,j,tmp,num,maxx,n,m,res; ll a[MAXN+],sum[MAXN+],h[MAXN+]; vector<ll&g…
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=2000),问满足[数列长度是k && 数列中每一个元素arr[i]在1~n之间 && 数列中元素可以重复]的数列有多少个?结果对10^9+7取余 解题思路:dp[i][j]表示长度是j,最后一位是i的种数 if(kk%i==0) dp[kk][j+1]+=dp[i][j] #inc…
1649:[例 2]2^k 进制数 时间限制: 1000 ms         内存限制: 524288 KB [题目描述] 原题来自:NOIP 2006 提高组 设 r 是个 2k 进制数,并满足以下条件: 1.r 至少是个 2 位的 2k 进制数. 2.作为 2k 进制数,除最后一位外,r 的每一位严格小于它右边相邻的那一位. 3.将 r 转换为 2 进制数 q 后,q 的总位数不超过 w. 在这里,正整数 k 和 w 是事先给定的. 问:满足上述条件的不同的 r 共多少个? [输入] 输入…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab ch…
[原题题面]传送门 [题面翻译]传送门 [解题思路] 操作涉及到区间求和和区间异或,考虑到异或操作,我们对每个数二进制分解. 把每一位单独提出来做,异或要么取反要么变为不变,对于每一位建一颗线段树,那么原题中的信息维护就相当于: 1.区间取反 2.区间求和 那就打标记传标记好了.. [code] #include<bits/stdc++.h> using namespace std; ; int n,q,abt,x,y,z; ][N]; ][N<<]; ][N<<],a…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output 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, b, and c. H…
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve i…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output The winter in Berland lasts n days. For each day we know the forecast for the average air temperature that day. Vasya has a new set of winter tir…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Vika has an infinite sheet of squared paper. Initially all squares are white. She introduced a two-dimensional coordinate system on this sheet a…