概述:不变序列算法,参见http://www.cplusplus.com/reference/algorithm/

/*
std::for_each
template <class InputIterator, class Function>
Function for_each (InputIterator first, InputIterator last, Function fn); Apply function to range
Applies function fn to each of the elements in the range [first,last).
[对[first, last)中的所有元素调用函数fn]
The behavior of this template function is equivalent to:
[该模板函数的行为与以下操作等价:]
template<class InputIterator, class Function>
Function for_each(InputIterator first, InputIterator last, Function fn)
{
while (first!=last) {
fn (*first);
++first;
}
return fn; // or, since C++11: return move(fn);
}
*/ #include <iostream>
#include <vector>
#include <algorithm> class myclass
{
public:
void operator() (int i)
{
std::cout<<' '<<i;
}
}; void myfunctoin (int i)
{
std::cout<<' '<<i;
} int main()
{
std::vector<int> myvec;
std::vector<int>::iterator it; for(int i=; i<; i++)
myvec.push_back(i+); std::cout<<"myvec contains:";
for_each(myvec.begin(), myvec.end(), myfunctoin);
std::cout<<'\n'; //or
myclass obj;
std::cout<<"myvec contains:";
for_each(myvec.begin(), myvec.end(), obj);
std::cout<<'\n'; system("pause");
return ;
}
/*
std::find
template <class InputIterator, class T>
InputIterator find (InputIterator first, InputIterator last, const T& val); Find value in range
Returns an iterator to the first element in the range [first,last) that compares equal to val. If no such element is found, the function returns last.
[返回[first, last)中第一个指向val的迭代器,如果没有找到则返回last]
The function uses operator== to compare the individual elements to val.
[该函数使用operator==来比较元素元素是否为val]
The behavior of this function template is equivalent to:
[该模板函数的行为与以下操作等价:]
template<class InputIterator, class T>
InputIterator find (InputIterator first, InputIterator last, const T& val)
{
while(first != last){
if(*first == val) return first;
++first;
}
return last;
}
*/ #include <iostream>
#include <vector>
#include <algorithm> int main()
{
// using std::find with array and pointer.
int myints[] = {, , , };
int *p; p = std::find(myints, myints+, );
if(p != myints+)
std::cout<<"Element found in myints: "<<*p<<'\n';
else
std::cout<<"Element not found in myints\n"; // using std::find with vector and iterator.
std::vector<int> myvector (myints, myints+);
std::vector<int>::iterator it; it = std::find(myvector.begin(), myvector.end(), );
if(it != myvector.end())
std::cout<<"Element found in myints: "<<*it<<'\n';
else
std::cout<<"Element not found in myints\n"; system("pause");
return ;
}
/*
std::find_if
template<class InputIterator, class UnaryPredicate>
InputIterator find_if (InputIterator first, InputIterator last, UnaryPredicate pred); Find element in range
Returns an iterator to the first element in the range [first,last) for which pred returns true. If no such element is found, the function returns last.
[返回[first, last)中第一个使得pred返回真的迭代器,如果没有找到,则返回last]
The behavior of this function template is equivalent to:
[该函数模板的行为等价于以下操作:]
template <class InputIterator, class UnaryPredicate>
InputIterator find_if (InputIterator first, InputIterator last, UnaryPredicate pred)
{
while(first != last){
if(pred(*first)) return first;
++first;
}
return last;
}
*/ #include <iostream>
#include <algorithm>
#include <vector> bool IsOdd (int i)
{
return ((i%) == );
} int main()
{
std::vector<int> myvector; myvector.push_back();
myvector.push_back();
myvector.push_back();
myvector.push_back(); std::vector<int>::iterator it = std::find_if(myvector.begin(), myvector.end(), IsOdd); if(it != myvector.end())
std::cout<<"The first odd value in myvector is "<<*it<<'\n';
else
std::cout<<"There is no odd value in myvector."<<'\n'; system("pause");
return ;
}
/*
//std::adjacent_find
template <class FowardIterator>
FowardIterator adjacent_find (FowardIterator first, FowardIterator last); template <class FowardIterator, class BinaryPredicate>
FowardIterator adjacent_find (FowardIterator first, FowardIterator last, BinaryPredicate pred); Find equal adjacent elements in range
Searches the range [first,last) for the first occurrence of two consecutive elements that match, and returns an iterator to the first of these two elements, or last if no such pair is found.
[在[fisrt, last)中寻找第一次匹配成功的两个连续元素,并返回指向其中第一个元素的迭代器,如果没有匹配成功,则返回last]
Two elements match if they compare equal using operator== (or using pred, in version (2)).
[默认使用operator==来判断两个元素是否匹配成功,或者使用pred来判断]
The behavior of this function template is equivalent to:
[该函数模板的行为等价于以下操作:]
template <class FowardIterator>
FowardIterator adjacent_find (FowardIterator first, FowardIterator last)
{
if(first != last)
{
FowardIterator next = first;
++next;
while(next != last){
if(*first == *next) return first;
++first; ++next;
}
return last;
}
}
*/ #include <iostream>
#include <algorithm>
#include <vector> bool myfunctoin(int i, int j)
{
return (i == j);
} int main()
{
int myints[] = {, , , , , , , , };
std::vector<int> myvector(myints, myints+);
std::vector<int>::iterator it; it = std::adjacent_find(myvector.begin(), myvector.end()); if(it != myvector.end())
std::cout<<"The first pair of repeated elements are "<<*it<<'\n'; it = std::adjacent_find(++it, myvector.end(), myfunctoin); if(it != myvector.end())
std::cout<<"The second pair of repeated elements are "<<*it<<'\n'; system("pause");
return ;
}
/*
std::find_end
template <class ForwardIterator1, class ForwardIterator2>
ForwardIterator1 find_end (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2); template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
ForwardIterator1 find_end (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); Find last subsequence in range
Searches the range [first1,last1) for the last occurrence of the sequence defined by [first2,last2), and returns an iterator to its first element, or last1 if no occurrences are found.
[在序列[first1, last2)中搜索出最后一个与序列[first2, last2)相匹配的子序列,并返回指向搜索到的子序列的第一个元素的迭代器,如果没有搜索到则返回last1]
The elements in both ranges are compared sequentially using operator== (or pred, in version (2)): A subsequence of [first1,last1) is considered a match only when this is true for all the elements of [first2,last2).
[比较两个序列中的元素是通过operator==来进行的(或者使用pred)]
This function returns the last of such occurrences. For an algorithm that returns the first instead, see search.
[该函数按返回的是最后一个匹配的子序列,如果想要得到第一个匹配的子序列,请看search算法]
The behavior of this function template is equivalent to:
[该函数模板的行为等价于以下操作:]
template <class ForwardIterator1, class ForwardIterator2>
ForwardIterator1 find_end (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2)
{
if (first2==last2) return last1; // specified in C++11 ForwardIterator1 ret = last1; while(first1 != last1)
{
ForwardIterator1 it1 = first1;
ForwardIterator2 it2 = first2;
while(*it1 == *it2){ // or: while (pred(*it1,*it2)) for version (2)
++it1; ++it2;
if(it2 == last2) {ret = first1; break;}
if(it1 == last1) return ret;
}
++first1;
}
return ret;
}
*/ #include <iostream>
#include <algorithm>
#include <vector> bool myfunctoin(int i, int j){
return (i==j);
} int main()
{
int myints[] = {, , , , , , , , , };
std::vector<int> myvector(myints, myints+); int needle1[] = {, , }; // using default comparison.
std::vector<int>::iterator it;
it = std::find_end(myvector.begin(), myvector.end(), needle1, needle1+); if(it != myvector.end())
std::cout<<"needle1 last found at position "<<(it - myvector.begin())<<'\n'; int needle2[] = {, , }; // using predicate comparison.
it = std::find_end(myvector.begin(), myvector.end(), needle2, needle2+, myfunctoin); if(it != myvector.end())
std::cout<<"needle2 last found at position "<<(it - myvector.begin())<<'\n'; system("pause");
return ;
}
/*
std::find_first_of
template <class ForwardIterator1, class ForwardIterator2>
ForwardIterator1 find_first_of (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2); template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
ForwardIterator1 find_first_of (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); Find element from set in range
Returns an iterator to the first element in the range [first1,last1) that matches any of the elements in [first2,last2). If no such element is found, the function returns last1.
[返回指向[first1, last1)中第一个与[first2, last2)中任一元素相匹配的元素的迭代器,如果没有找到则返回last1]]
The elements in [first1,last1) are sequentially compared to each of the values in [first2,last2) using operator== (or pred, in version (2)), until a pair matches.
[元素的比较是通过operator==来进行的(或者通过pred)]
The behavior of this function template is equivalent to:
[该函数模板的行为等价于以下操作:] template <class ForwardIterator1, class ForwardIterator2>
ForwardIterator1 find_first_of (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2)
{
while(first1 != last1){
for(ForwardIterator2 it2 = first2; it2 != last2; ++it2){
if(*it2 == *first1) // or: if (pred(*it,*first)) for version (2)
return first1;
}
++first1;
}
return last1;
}
*/ #include <iostream> // std::cout
#include <algorithm> // std::find_first_of
#include <vector> // std::vector
#include <cctype> // std::tolower bool comp_case_insensitive (char c1, char c2) {
return (std::tolower(c1)==std::tolower(c2));
} int main () {
int mychars[] = {'a','b','c','A','B','C'};
std::vector<char> haystack (mychars,mychars+);
std::vector<char>::iterator it; int needle[] = {'A','B','C'}; // using default comparison:
it = find_first_of (haystack.begin(), haystack.end(), needle, needle+); if (it!=haystack.end())
std::cout << "The first match is: " << *it << '\n'; // using predicate comparison:
it = find_first_of (haystack.begin(), haystack.end(),
needle, needle+, comp_case_insensitive); if (it!=haystack.end())
std::cout << "The first match is: " << *it << '\n'; system("pause");
return ;
}
/*
std::equal
template <class InputItertor1, class InputIterator2>
bool equal (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); template <class InputIterator1, class InputIterator2, class BinaryPredicate>
bool equal (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred); Test whether the elements in two ranges are equal
[比较两个范围中的元素是否相等]
Compares the elements in the range [first1,last1) with those in the range beginning at first2, and returns true if all of the elements in both ranges match.
[将[first1, last1)中的元素与以first2为起点的相同范围内的元素进行比较,如果两个范围中的元素全部相等则返回真]
The elements are compared using operator== (or pred, in version (2)).
[元素间通过operator==进行比较(或者使用pred)]
The behavior of this function template is equivalent to:
[该函数模板的行为等价于以下操作:]
template <class InputIterator1, class InputIterator2>
bool equal (InputIterator1 first1, InputIterator2 last1, InputIterator2 first2)
{
while(first1 != last1){
if(!(*first1 == *first2)) // or: if (!pred(*first1,*first2)), for version 2
return false;
++first1; ++first2;
}
return true;
}
*/ #include <iostream>
#include <algorithm>
#include <vector> bool mypredicate(int i, int j)
{
return (i == j);
} int main()
{
int myints[] = {, , , , };
std::vector<int> myvector(myints, myints+); if(std::equal(myvector.begin(), myvector.end(), myints))
std::cout<<"The contents of both sequences are equal.\n";
else
std::cout<<"The contents of both sequences differ.\n"; myvector[] = ; if(std::equal(myvector.begin(), myvector.end(), myints, mypredicate))
std::cout<<"The contents of both sequences are equal.\n";
else
std::cout<<"The contents of both sequences differ.\n"; system("pause");
return ;
}
/*
std::mismatch
template <class InputIterator1, class InputIterator2>
pair<InputIterator1, InputIterator2> mismatch (InputIterator1 first1, InputIterator1 last1, InputIterator1 first2); template <class InputIterator1, class InputIterator2, class BinaryPredicate>
pair<InputIterator1, InputIterator2> mismatch (InputIterator1 first1, InputIterator1 last1, InputIterator1 first2, BinaryPredicate pred); Return first position where two ranges differ
Compares the elements in the range [first1,last1) with those in the range beginning at first2, and returns the first element of both sequences that does not match.
[比较[first1, last1)与[fist2, last2)之间的元素,并返回两者第一个不匹配的元素]
The elements are compared using operator== (or pred, in version (2)).
[元素间的比较通过operator==来进行(或者通过pred)]
The function returns a pair of iterators to the first element in each range that does not match.
[该函数的返回值类型是pair,其中的两个参数是指向两个区间中不匹配元素的迭代器]
The behavior of this function template is equivalent to:
[该函数模板的行为等价于以下操作:] template <class InputIterator1, class InputIterator2>
pair<InputIterator1, InputIterator2> mismatch (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2 )
{
while ( (first1!=last1) && (*first1==*first2) ) // or: pred(*first1,*first2), for version 2
{ ++first1; ++first2; }
return std::make_pair(first1,first2);
}
*/ #include <iostream>
#include <algorithm>
#include <vector>
#include <utility> //std::pair bool mypredicate(int i, int j){
return (i==j);
} int main()
{
std::vector<int> myvector;
for(int i=; i<; i++) myvector.push_back(i*); int myints[] = {, , , , }; std::pair<std::vector<int>::iterator, int*> mypair; // using default comparison
mypair = std::mismatch(myvector.begin(), myvector.end(), myints);
std::cout<<"First mismatch elements: "<<*mypair.first<<" and "<<*mypair.second<<'\n'; // using predicate comparison
mypair = std::mismatch(++mypair.first, myvector.end(), ++mypair.second, mypredicate);
std::cout<<"Second mismatch elements: "<<*mypair.first<<" and "<<*mypair.second<<'\n'; system("pause");
return ;
}
/*
template <class ForwardIterator1, class ForwardIterator2>
ForwardIterator1 search (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator1 first2, ForwardIterator1 last2); template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
ForwardIterator1 search (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator1 first2, ForwardIterator1 last2, BinaryPredicate pred); Search range for subsequence
Searches the range [first1,last1) for the first occurrence of the sequence defined by [first2,last2), and returns an iterator to its first element, or last1 if no occurrences are found.
[在[first1, last1)中搜索第一个与序列[first2, last2)相匹配的子序列,并返回指向搜索到的子序列的第一个元素的迭代器,如果没有搜索到则返回last1]
The elements in both ranges are compared sequentially using operator== (or pred, in version (2)): A subsequence of [first1,last1) is considered a match only when this is true for all the elements of [first2,last2).
[元素的比较是通过operator==来进行的(或者通过pred)]
This function returns the first of such occurrences. For an algorithm that returns the last instead, see find_end.
[该函数返回第一个与给定序列匹配的子序列,如果想要返回最后一个,请参看find_end.]
The behavior of this function template is equivalent to:
[该函数模板的行为等价于以下操作:] template <class ForwardIterator1, class ForwardIterator1>
ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator1 first2, ForwardIterator1 last2)
{
if(first2 == last2) return first1; // specified in C++11 while(first1 != last1)
{
ForwardIterator1 it1 = first1;
ForwardIterator2 it2 = first2;
while(*it1 == *it2){ // or pred(*it1, *it2) for verson 2
++it1; ++it2;
if(it2 == last2) return first1;
if(it1 == last1) return last1;
}
++first1;
}
return last1;
}
*/ #include <iostream>
#include <algorithm>
#include <vector> bool mypredicate(int i, int j){
return (i==j);
} int main()
{
std::vector<int> myvector;
for(int i=; i<; i++) myvector.push_back(i*);
std::vector<int>::iterator it; // using default comparison.
int needle1[] = {, , , };
it = std::search(myvector.begin(), myvector.end(), needle1, needle1+); if(it != myvector.end())
std::cout<<"needle1 found at position "<<it-myvector.begin()<<'\n';
else
std::cout<<"needle1 not found.\n"; // using predicate comparison.
int needle2[] = {, , };
it = std::search(myvector.begin(), myvector.end(), needle2, needle2+, mypredicate); if(it != myvector.end())
std::cout<<"needle2 found at position "<<it-myvector.begin()<<'\n';
else
std::cout<<"needle2 not found.\n"; system("pause");
return ;
}
/*
template <class ForwardIterator, class Size, class T>
ForwardIterator search_n (ForwardIterator first, ForwardIterator last, Size count, const T& val); template <class ForwardIterator, class Size, class T, class BinaryPredicate>
ForwardIterator search_n (ForwardIterator first, ForwardIterator last, Size count, const T& val, BinaryPredicate pred); Search range for elements
Searches the range [first,last) for a sequence of count elements, each comparing equal to val (or for which pred returns true).
[在[first, last)中搜索是否连续出现count次val]
The function returns an iterator to the first of such elements, or last if no such sequence is found.
[该函数返回指向第一个等于val的元素的迭代器,如果没有找到则返回last]
The behavior of this function template is equivalent to:
[该函数模板的行为等价于以下操作:] template<class ForwardIterator, class Size, class T>
ForwardIterator search_n (ForwardIterator first, ForwardIterator last, Size count, const T& val)
{
ForwardIterator it, limit;
Size i; limit=first; std::advance(limit,std::distance(first,last)-count); //注:私认为应该是std::advance(limit, std::distance(first, last)-count+1) while (first!=limit)
{
it = first; i=0;
while (*it==val) // or: while (pred(*it,val)) for the pred version
{ ++it; if (++i==count) return first; }
++first;
}
return last;
}
*/ #include <iostream> // std::cout
#include <algorithm> // std::search_n
#include <vector> // std::vector bool mypredicate (int i, int j) {
return (i==j);
} int main () {
int myints[]={,,,,,,,};
std::vector<int> myvector (myints,myints+); std::vector<int>::iterator it; // using default comparison:
it = std::search_n (myvector.begin(), myvector.end(), , ); if (it!=myvector.end())
std::cout << "two 30s found at position " << (it-myvector.begin()) << '\n';
else
std::cout << "match not found\n"; // using predicate comparison:
it = std::search_n (myvector.begin(), myvector.end(), , , mypredicate); if (it!=myvector.end())
std::cout << "two 10s found at position " << int(it-myvector.begin()) << '\n';
else
std::cout << "match not found\n"; system("pause");
return ;
}
/*
std::count
template <class InputIterator, class T>
typename iterator_traits<InputIterator>::difference_type count (InputIterator first, InputIterator last, const T& val); Count appearances of value in range
Returns the number of elements in the range [first,last) that compare equal to val.
[返回[first, last)中与val相等的元素的个数]
The function uses operator== to compare the individual elements to val.
[该函数使用operator==来判断元素是否等于val]
The behavior of this function template is equivalent to:
[该函数模板的行为等价于以下操作:]
template <class InputIterator, class T>
typename iterator_traits<InputIterator>::difference_type
count (InputIterator first, InputIterator last, const T& val)
{
typename iterator_traits<InputIterator>::difference_type ret = 0;
while(first != last){
if(*first == val) ++ret;
++first;
}
return ret;
}
*/ #include <iostream>
#include <algorithm>
#include <vector> int main()
{
int myints[] = {, , , , , , , };
int mycount = std::count(myints, myints+, );
std::cout<<"10 appears "<<mycount<<" times.\n"; std::vector<int> myvector(myints, myints+);
mycount = std::count(myvector.begin(), myvector.end(), );
std::cout<<"20 appears "<<mycount<<" times.\n"; system("pause");
return ;
}
/*
template <class InputIterator, class UnaryPredicate>
typename iterator_traits<InputIterator>::difference_type count_if (InputIterator first, InputIterator last, UnaryPredicate pred); Return number of elements in range satisfying condition
[返回区间中满足条件的元素个数]
Returns the number of elements in the range [first,last) for which pred is true.
[返回[first, last)中使得pred返回真的元素个数]
The behavior of this function template is equivalent to:
[该函数模板的行为等价于以下操作:] template <class InputIterator, class UnaryPredicate>
typename iterator_traits<InputIterator>::difference_type count_if (InputIterator first, InputIterator last, UnaryPredicate pred)
{
typename iterator_traits<InputIterator>::difference_type ret = 0;
while(first != last)
{
if(pred(*first)) ++ret;
first++;
}
return ret;
}
*/ #include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <utility> class stuRecord
{
public:
class stuInfo
{
public:
void setName(std::string m_name) {name = m_name;}
void setAge(int m_age) {age = m_age;}
void setAddr(std::string m_addr) {addr = m_addr;} std::string getName() const {return name;}
int getAge() const {return age;}
std::string getAddr() const {return addr;} private:
std::string name;
int age;
std::string addr;
}; private:
int id;
stuInfo m_stuInfo; public:
stuRecord(int m_id, std::string m_name, int m_age, std::string m_addr)
{
id = m_id;
m_stuInfo.setName(m_name);
m_stuInfo.setAge(m_age);
m_stuInfo.setAddr(m_addr);
} int getId() const {return id;}
stuInfo getStuInfo() const {return m_stuInfo;}
}; typedef stuRecord::stuInfo stuRI; bool setRange(std::pair<int, stuRI> stu)
{
return ((stu.second.getAge() > ) && (stu.second.getAge() < ));
} int main()
{
stuRecord stu1(, "张三", , "上海");
stuRecord stu2 = stuRecord(, "李四", , "上海");
stuRecord stu3 = stuRecord(, "王五", , "深圳");
stuRecord stu4 = stuRecord(, "赵六", , "长沙");
stuRecord stu5 = stuRecord(, "孙七", , "广东"); std::map<int, stuRI> mymap;
mymap.insert(std::make_pair(stu1.getId(), stu1.getStuInfo()));
mymap.insert(std::make_pair(stu2.getId(), stu2.getStuInfo()));
mymap.insert(std::make_pair(stu3.getId(), stu3.getStuInfo()));
mymap.insert(std::make_pair(stu4.getId(), stu4.getStuInfo()));
mymap.insert(std::make_pair(stu5.getId(), stu5.getStuInfo())); int mycount = std::count_if(mymap.begin(), mymap.end(), setRange);
std::cout<<"The number of students whose age between 20 and 30 is "<<mycount<<'\n'; system("pause");
return ;
}

algorithm之不变序列操作的更多相关文章

  1. 【BZOJ-2962】序列操作 线段树 + 区间卷积

    2962: 序列操作 Time Limit: 50 Sec  Memory Limit: 256 MBSubmit: 678  Solved: 246[Submit][Status][Discuss] ...

  2. 【BZOJ-1858】序列操作 线段树

    1858: [Scoi2010]序列操作 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 1961  Solved: 991[Submit][Status ...

  3. BZOJ 1858: [Scoi2010]序列操作( 线段树 )

    略恶心的线段树...不过只要弄清楚了AC应该不难.... ---------------------------------------------------------------- #inclu ...

  4. [bzoj]2962序列操作

    [bzoj]2962序列操作 标签: 线段树 题目链接 题意 给你一串序列,要你维护三个操作: 1.区间加法 2.区间取相反数 3.区间内任意选k个数相乘的积 题解 第三个操作看起来一脸懵逼啊. 其实 ...

  5. bzoj 2962 序列操作

    2962: 序列操作 Time Limit: 50 Sec  Memory Limit: 256 MB[Submit][Status][Discuss] Description 有一个长度为n的序列, ...

  6. SCOI2010 序列操作

    2421 序列操作 http://codevs.cn/problem/2421/ 2010年省队选拔赛四川   题目描述 Description lxhgww最近收到了一个01序列,序列里面包含了n个 ...

  7. bzoj1858[Scoi2010]序列操作 线段树

    1858: [Scoi2010]序列操作 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 3079  Solved: 1475[Submit][Statu ...

  8. BZOJ_1858_[Scoi2010]序列操作_线段树

    BZOJ_1858_[Scoi2010]序列操作_线段树 Description lxhgww最近收到了一个01序列,序列里面包含了n个数,这些数要么是0,要么是1,现在对于这个序列有五种变换操作和询 ...

  9. BZOJ1500: [NOI2005]维修数列 [splay序列操作]【学习笔记】

    以前写过这道题了,但我把以前的内容删掉了,因为现在感觉没法看 重写! 题意: 维护一个数列,支持插入一段数,删除一段数,修改一段数,翻转一段数,查询区间和,区间最大子序列 splay序列操作裸题 需要 ...

随机推荐

  1. 在XML序列化时去除默认命名空间xmlns:xsd和xmlns:xsi

    摘 自: http://blog.csdn.net/fxhflower/article/details/7276820 可使用以下代码: //Create our own namespaces for ...

  2. gdb调试工具使用方法分享

    刚才看了一个CSDN上分享gdb调试工具使用的教程,讲得非常好,推荐到这里: http://blog.csdn.net/liigo/article/details/582231

  3. HTML5应用之时钟

    利用HTML5的Canvas API可以完成我们以前意想不到的动画效果,以前我们想在网页上放置一个时钟,需要先用flash工具制作一个钟表,并写上复杂的JavaScript代码,然后载入到页面中.而H ...

  4. C# 执行JS

    需引用命名空间:Microsoft.VsaMicrosoft.JScript using System; using System.Collections.Generic; using System. ...

  5. android 分段显示文本颜色控件

    效果: 使用: <com.bei.myapplication.app.ProgressTextView xmlns:ptv="http://schemas.android.com/ap ...

  6. ThinkPHP实现联动菜单;

    联动菜单,首先给你看看前端是怎么写的:

  7. Windos中无法删除桌面IE图标的解决方法

    解决方法其实并不难,打开注册表,转到如下图的位置,详细地址在图片最下面: 需要注意的是,你需要在NameSpace中逐个查看各个项目的数据值,显示为数据值为Internet Explorer的项目即为 ...

  8. MySQL性能优化笔记整理

    一.测试篇 1.测试目的,就是量化找出短板(基础参数配置) 2.测试三大指标 IOPS:每秒处理的IO请求数,即IO响应速度(注意和IO吞吐量的区别) QPS:每秒请求(查询)次数 TPS:每秒事务数 ...

  9. spark 集合交集差集运算

    intersect except是spark提供的集合差集运算, 但是要求参与运算的两个dataframe,有相同的data Schema. 如果我想从 集合1(attribute1, attribu ...

  10. 第二章 管理程序流(In .net4.5) 之 管理多线程

    1. 概述 本章包括同步资源以及取消长时间任务相关的内容. 2. 主要内容 2.1 同步资源 ① lock关键字实现.会阻塞程序,有可能会导致死锁. ② volatile关键字可以禁用编译优化,用于避 ...