摘要: 一列一列地推就可以了 cpp include include using namespace std; typedef long long ll; int n, m; const int mod=10000007; struct Matrix{ int num[15][15]; Matrix ope 阅读全文
posted @ 2018-03-12 20:52 poorpool 阅读(176) 评论(0) 推荐(0)
摘要: 分治即可 当然也可以把矩阵看成元素用矩阵快速幂做 cpp include include using namespace std; int n, k, m; struct Matrix{ int num[35][35]; Matrix operator (const Matrix &x)const{ 阅读全文
posted @ 2018-03-12 19:21 poorpool 阅读(94) 评论(0) 推荐(0)
摘要: 欲求 $\sum_{i=1}^n (i,n)$。 显然 $(i,n) \mid n$。记 $d=(i,n)$,枚举 $d$,有多少个 $i \in [1,n]$ 使得 $(i,n)=d$ 呢?换句话说有多少个 $i \in [1,\lfloor n/d \rfloor]$ 使得 $(i,\lfloo 阅读全文
posted @ 2018-03-12 16:48 poorpool 阅读(90) 评论(0) 推荐(0)
摘要: 先筛法求出 $[1,n]$ 间的素数,然后枚举每个素数。可以发现,对于每个素数 $x$,它的贡献是 $[1,\lfloor n/x \rfloor]$ 间的有序互质对数。 我们钦定 $(x,y)$ 是 $x \leq y$ 的,发现 $x=y$ 是合法的当且仅当 $x=y=1$。这样就有 $x in 阅读全文
posted @ 2018-03-12 15:22 poorpool 阅读(127) 评论(0) 推荐(0)
摘要: 神贪心……写了一个晚上加一个早上。 先考虑只有一个宿管的情况。 首先,如果这个宿舍人多了,多余的人就跑到下一个宿舍。(如果这是最后一个宿舍的话,多的就躺床底下) 如果这个宿舍人少了,但是能从别的宿舍调过来人,那就调人。 如果这个宿舍人少了,从别的宿舍也调不过来足够的人,那就全跑到下一个宿舍去。 让宿 阅读全文
posted @ 2018-03-12 09:51 poorpool 阅读(986) 评论(0) 推荐(0)