Harmonic Number (II)】的更多相关文章

http://lightoj.com/volume_showproblem.php?problem=1245 G - Harmonic Number (II) Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1245 Description I was trying to solve problem '1234 - Harmonic…
1245 - Harmonic Number (II)   PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limit: 32 MB I was trying to solve problem '1234 - Harmonic Number', I wrote the following code long long H( int n ) {     long long res = 0;     for( int i =…
/** 题目:G - Harmonic Number (II) 链接:https://vjudge.net/contest/154246#problem/G 题意:给定一个数n,求n除以1~n这n个数的和.n达到2^31 - 1; 思路: 首先我们观察一下数据范围,2^31次方有点大,暴力会超时,所以我们看看有没有啥规律,假设 tmp 是 n/i 的值,当n == 10的时候(取具体值) 当 tmp = 1 时,个数 是10/1 - 10/2 == 5个 当 tmp = 2 时,个数 是10/2…
题目链接:https://vjudge.net/problem/LightOJ-1245 1245 - Harmonic Number (II)    PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limit: 32 MB I was trying to solve problem '1234 - Harmonic Number', I wrote the following code long long H( int…
Harmonic Number (II)   PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limit: 32 MB I was trying to solve problem '1234 - Harmonic Number', I wrote the following code long long H( int n ) {    long long res = 0;    for( int i = 1; i <= …
链接: https://vjudge.net/problem/LightOJ-1245 题意: I was trying to solve problem '1234 - Harmonic Number', I wrote the following code long long H( int n ) { long long res = 0; for( int i = 1; i <= n; i++ ) res = res + n / i; return res; } Yes, my error…
I was trying to solve problem '1234 - Harmonic Number', I wrote the following code long long H( int n ) {    long long res = 0;    for( int i = 1; i <= n; i++ )        res = res + n / i;    return res;} Yes, my error was that I was using the integer…
题意 \(求\Sigma \lfloor \frac{n}{i} \rfloor\) Input starts with an integer T (≤ 1000), denoting the number of test cases. Each case starts with a line containing an integer n (1 ≤ n < 2^31). Sol 数论分块 # include <bits/stdc++.h> # define RG register #…
http://lightoj.com/volume_showproblem.php?problem=1245 题目大意:一个数n除以1到n之和 分析:暴力肯定不行,我们可以先求1~sqrt(n)之间的每个数的个数,然后再求n除以1~sqrt(n)之间的数的和 这样算下来就只有2*sqrt(n)的复杂度 最后还要排除多加的,. #include<stdio.h> #include<string.h> #include<stdlib.h> #include<algor…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1245 题意就是求 n/i (1<=i<=n) 的取整的和这就是到找规律的题, i     1  2   3   4   5   6   7    8 a    8  4   2   2   1   1   1    1 你可以多写几组你会发现 有8-4个1:4-2个2:...其他例子也是这样: 当n = 10时 n/1 = 10, n/2 = 5说明(5, 10]这个前开后闭的区间…