Title Link: http://acm.fzu.edu.cn/problem.php?pid=2104
Problem Description
In this problem, we have F (n,x) =floor[n/x]. Here Floor[x] are the biggest integer such that no larger than X. For example, Floor[1.1]=floor[1.9]=1, floor[2.0]=2.
You are given 3 positive integers n, L and R. Print The result of f (n,l) +f (n,l+1) +...+f (n,r), please.
Input
The first line of the input contains an integer T (t≤100), indicating the number of the test cases.
Then T-cases, for any case, only 3 integers n, l and R (1≤n, L, r≤10,000, L≤r).
Outputfor each test case, print the result of f (n,l) +f (n,l+1) +...+f (n,r) in a single line. Sample INPUT31 2 3100 2 100100 3 sample Output0382332 Source "Higher Education Cup" the third Fujian University student Program Design Contest
The code is as follows:
#include <cstdio> #include <cmath>int main () { int t; int N, l, R; scanf ("%d", &t); while (t--) { scanf ("%d%d%d", &n,&l,&r); Double sum = 0; for (int i = l; I <= R; i++) { sum+=floor (n*1.0/i); } printf ("%.0lf\n", sum); } return 0;}
Fzu problem 2104 Floor problem (math AH)