HDU 6134】的更多相关文章

[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6134 [题目大意] 求$\sum_{i=1}^{n}{\sum_{j=1}^{i}\lceil{\frac{i}{j}}\rceil}[ (i,j)==1 ]$ [题解] 设 $g(i)=\sum_{i=1}^{n}{\sum_{j=1}^{i}\lceil{\frac{i}{j}}\rceil}$,$h(i)=\sum_{i=1}^{n}{\sum_{j=1}^{i}\lceil{\frac{…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6134 题意: 解法: 那么g(n)怎么求,我们尝试打表发现g(n)是有规律的,g(n)=g(n-1)+d(n-1)+1,其中d(i)表示i的因子个数,这个我们是可以通过线性筛O(n)处理出来的,之后再O(n)维护g(i)的前缀和,就可以在单组sqrt(n)的复杂度下得到答案了. #include <bits/stdc++.h> using namespace std; typedef long l…
Battlestation Operational Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description > The Death Star, known officially as the DS-1 Orbital Battle Station, also known as the Death Star I, the First Death S…
题目链接 Problem Description The Death Star, known officially as the DS-1 Orbital Battle Station, also known as the Death Star I, the First Death Star, Project Stardust internally, and simply the Ultimate Weapon in early development stages, was a moon-si…
题意略. 思路: 我们先不考虑[(i , j) == 1],在此情况下,其实这个值是sum( [ (i , j) == 1,2,3,....,n ] ) 这些情况.我们要求的仅仅是其中的第一部分而已.也即: F(1) = f(1) + f(2) + f(3) + .... + f(n).[1,2,3,....,n 是1的整数倍] 在这里,我们令 g(i) 为 i / 1 + i / 2 + .... + i / i 向下取整之和.令 G(i) 为 左式向上取整之和,我们有一个递推公式: g(i)…
破结论没听说过,上式推导到第三步的时候有了O(nlogn) 的做法(枚举倍数+1最后前缀和),并且这种做法可以直接应用到向上取整的计算中,详见forever97 但由于d(n)是积性函数,故可O(n)求 代码参考这里 #include <bits/stdc++.h> using namespace std; #define LL long long const int N = 1e6+5; const LL MOD = 1e9+7; LL f[N], g[N]; void init() { f…
题目链接 比赛时没抓住重点,对那个受限制的“分数求和”太过关心了..其实如果先利用莫比乌斯函数的一个性质把后面那个[gcd(i,j)=1]去掉,那么问题就可以简化很多.公式如下 这和之前做过的一道题很相似..(见http://www.cnblogs.com/Just--Do--It/p/7326572.html) 这个式子显然是可以用分块+预处理mu[i]前缀和的方法来做. 预处理复杂度是O(n),分块解决单组询问复杂度是O(sqrt(n)) 求g[n]可以用递推式来解决. 对比g[n]和g[n…
Problem Description   > The Death Star, known officially as the DS-1 Orbital Battle Station, also known as the Death Star I, the First Death Star, Project Stardust internally, and simply the Ultimate Weapon in early development stages, was a moon-siz…
Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7194    Accepted Submission(s): 3345 Problem Description 话说上回讲到海东集团面临内外交困,公司的元老也只剩下XHD夫妇二人了.显然,作为多年拼搏的商人,XHD不会坐以待毙的.  一天,当他正在苦思冥想解困良策的…
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; int jc[100003]; int p; int ipow(int x, int b) { ll t = 1, w = x;…