摘要: 原题:http://www.caioj.cn/problem.php?id=1249题解:对于暴力的单点插入,需要将后面的全部移动,可以将数列分块,sqrt(n)的块暴力。当在同一个块插入过多次时需要重构。不放每 sqrt(n)重构一次,可以保证复杂度。#includ... 阅读全文
posted @ 2019-01-10 18:18 Exception2017 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 原题:http://www.caioj.cn/problem.php?id=1249题解:显然区间开方比较难做,但很容易发现2^32的数开4-5次方就会到1,考虑分块暴力,如果这个快全部是1的化就不用再维护,最坏的情况是1-n开4-5次方,可以接受。这道题加点小优化就... 阅读全文
posted @ 2019-01-10 14:19 Exception2017 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 原题:https://loj.ac/problem/6280题解:这题不太难,分块求区间和就行了。#include#define reg register#define N 50001#define M 300#define ll long longusing nam... 阅读全文
posted @ 2019-01-09 20:42 Exception2017 阅读(261) 评论(0) 推荐(0) 编辑
摘要: 原题:http://www.caioj.cn/problem.php?id=1246题解:本题要查询前驱,即比x小的最大值。考虑分块,对每个块排序,二分查找x,维护个最大值。#include#include#include#include#include#define... 阅读全文
posted @ 2019-01-08 22:20 Exception2017 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 原题:http://www.caioj.cn/problem.php?id=1245题解:我们可以分块处理。两边的块暴力,中间的块可以先预处理排序,再用lower_bound求出个数。#include#include#include#include#include#d... 阅读全文
posted @ 2018-12-23 22:40 Exception2017 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 原题:http://www.caioj.cn/problem.php?id=1244题解:对于区间的所有元素加c并要求单点的值。显然可以用线段树来求,但本篇要用新的方法来求。令:m为每一个块的大小,且m为根号n向下取整。每个块大小为m,共有n/m个块由于每次不完整的块... 阅读全文
posted @ 2018-12-23 22:36 Exception2017 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 原题:http://codeforces.com/contest/338/problem/D题解:基本题意:是否存在。可以设:整理得:这样就可以用合并方程的方法求出x和lcm,而行数i就为lcm。检验答案是否正确就可以了。注意:这道题数较大要用到快速乘。#includ... 阅读全文
posted @ 2018-12-23 21:15 Exception2017 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 原题:poj.org/problem?id=2480题目:求。可以枚举gcd即:变形一下:,这样就转化为:个gcd为g的数答案为:#include#include#include#ifdef WIN32#define LLD "%I64d"#else#define L... 阅读全文
posted @ 2018-12-15 20:33 Exception2017 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 原题:http://acm.hdu.edu.cn/showproblem.php?pid=3501题解:求比n小且不互质的数的和。可以先求互质数的和即:证明如下:有:即质数总是成对存在的且相加为n共有个,所以和为。答案为:#include#include#define... 阅读全文
posted @ 2018-12-15 20:11 Exception2017 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 原题:http://acm.hdu.edu.cn/showproblem.php?pid=2588题解:求1=M.的个数。题目中的n很大我么可以考虑枚举gcd。显然对于每个gcd都应为N的因数。即且变形下的:对于gcd为g的a的个数显然是 #include#inclu... 阅读全文
posted @ 2018-12-15 20:02 Exception2017 阅读(122) 评论(0) 推荐(0) 编辑