题意: long long H(int n){ long long res = 0; for( int i = 1; i <= n; i=i+1 ){ res = (res + n/i); } return res;} 求这样一个函数的值. 分析: 这个题很像我做莫比乌斯反演时的一个分块加速的优化. 注意到n/i的整数部分,有许多重复的数.具体一点,对于某一个i,在区间[i, n / (n / i)]中n/i的值是一样的. 例如在[17, 20]中的i,100/i的值都是5. #include…
What is the value this simple C++ function will return? long long H(int n) { ; ; i <= n; i=i+ ) { res = (res + n/i); } return res; } Input The first line of input is an integer T (T ≤ 1000) that indicates the number of test cases. Each of the next T…
Couple doubi 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/D Description DouBiXp has a girlfriend named DouBiNan.One day they felt very boring and decided to play some games. The rule of this game is as following. There are k balls on th…
HazelFan is given two positive integers a,b, and he wants to calculate amodb. But now he forgets the value of b and only remember the value of a, please tell him the number of different possible results. Input The first line contains a positive integ…