# Lruihao's Note

## 1 K. 2018

Given a,b,c,d, ﬁnd out the number of pairs of integers (x,y) where a ≤ x ≤ b,c ≤ y ≤ d and x·y is a multiple of 2018.

## 1 B. Higher h-index

The h-index of an author is the largest h where he has at least h papers with citations not less than h.
Bobo has no papers and he is going to publish some subsequently. If he works on a paper for x hours, the
paper will get (a·x) citations, where a is a known constant. It’s clear that x should be a positive integer.
There is also a trick – one can cite his own papers published earlier.

Given Bobo has n working hours, ﬁnd the maximum h-index of him.

## 1 A. Easy h-index

The h-index of an author is the largest h where he has at least h papers with citations not less than h.
Bobo has published many papers. Given a0,a1,a2,…,an which means Bobo has published ai papers with
itations exactly i, ﬁnd the h-index of Bobo.

## sort 排序

sort 使用#include<algorithm>头文件， sort（开始地址，结束地址，排序方式），其中第三参数可以没有，则默认为升序排序。 或者简单的用 less<参数类型>()表示升序 greater<参数类型>()表示降序 也可以用一个 bool 型函数，比如： 1 2 3 4 5 bool cmp(int a,int b){ return

## C++ with STL

1 1.swap（交换两元素值，在 algorithm 下，用法：swap(a,b);）交换两元素的值在 C 语言课上作为指针讲解的典例。 int a=1,b=2; swap(a,b); //此时 a=2,b=1 （可以是其他类型） 2 2.sort(,,)sort 排序是不稳定的，stl 中的 stable_sort 才是稳定的 1 2 3 4 5 6 7 inta[10]={1,6,2,3,5,4,3,8,9,7}; stable_sort(a,a+10,greater<int>()); for(int i=0;i<10;i++) cout<<a[i]<<" "; 3 3.reverse（翻转序列，在 algorithm 下）//常用在字符串上 int a[5]={1,2,3,4,5}; reverse(a,a+5); //序列现在是 5 4 3 2

## 位运算

1 1. &运算&运算通常用于二进制取位操作，例如一个数 & 1 的结果就是取二进制的最末位。这可以用来判断一个整数的奇偶，二进制的最末位为 0 表示该数为偶数，最末位为 1 表示该数为奇数。 2 2. |运算|运算通常用于二进制特定位上的无条件赋值，例如一个数 or 1 的结果就是把二进制最末位强行变成 1。如果需要把