B. Expansion coefficient of the array time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Let's call an array of non-negative integers a1,a2,…,an a k-extension for some non-negative integer k i…
二次联通门 : Codeforces 221d D. Little Elephant and Array /* Codeforces 221d D. Little Elephant and Array 题意 : 询问一段区间中出现次数等于自身的数的个数 正解是dp 莫队水过, 作为我莫队的入门题 myj的思路 66 把所有需查询的区间排序 当前查询区间的答案为上一个区间的答案通过多次的区间移动得出 */ #include <algorithm> #include <cstdio>…
A. Array 题目连接: http://www.codeforces.com/contest/300/problem/A Description Vitaly has an array of n distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: The product of all numbers in the…
题目链接: http://codeforces.com/problemset/problem/498/C C. Array and Operations time limit per test1 secondmemory limit per test256 megabytes 问题描述 You have written on a piece of paper an array of n positive integers a[1], a[2], ..., a[n] and m good pair…
传送门:http://codeforces.com/contest/1108/problem/E2 E2. Array and Segments (Hard version) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The only difference between easy and hard versions i…
题目链接:http://codeforces.com/problemset/problem/558/B 题目意思:给出一个序列,然后找出出现次数最多,但区间占用长度最短的区间左右值. 由于是边读入边比较,因此问题最关键的是,记录每个数第一次出现的位置,即左值.因为要保证次数是出现最多,因此需要一个cnt[]数组来记录出现次数.然后当最多出现次数与当前cnt[x]次数相同时,要选择区间较短的,再更新左右区间值. 赛中短路竟然想不出来~~~泪啊~~泪啊- >_< #include <iost…
题目链接:http://codeforces.com/problemset/problem/295/A 我的做法,两次线段树 #include <cstdio> #include <cstring> const int N = 100005; long long sumv[N * 3]; long long add[N * 3]; long long a[N]; struct opera { int l, r; long long d; } op[N]; void pushdown…
time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: standard output Ayoub had an array aaa of integers of size nnn and this array had two interesting properties: All the integers in the array were between…
Codeforces 洛谷:咕咕咕 CF少有的大数据结构题. 思路 考虑一些欧拉函数的性质: \[ \varphi(p)=p-1\\ \varphi(p^k)=p^{k-1}\times (p-1)=p^k \times \frac{p-1}{p},k>0\\ \varphi(ab)=\varphi(a)\varphi(b),gcd(a,b)=1\\ \dots \] 有上面三个就够了. 要求 \[ \varphi(\prod a_i) \] 可以考虑把\(\prod a_i\)拆成 \[ \p…
Please, another Queries on Array? 利用欧拉函数的计算方法, 用线段树搞一搞就好啦. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair<LL, int> #define PII pair<int, i…