FZOJ2104:Floor problem

来源:互联网 发布:软件工程学不学高数 编辑:程序博客网 时间:2024/05/16 15:52
Problem Description

In this problem, we have f(n,x)=Floor[n/x]. Here Floor[x] is 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 test cases.

Then T cases, for any case, only 3 integers n, L and R (1≤n, L, R≤10,000, L≤R).

Output

For each test case, print the result of f(n,L)+f(n,L+1)+...+f(n,R) in a single line.

Sample Input

3
1 2 3
100 2 100
100 3 100

Sample Output

0
382
332
 
题意:给出,n,l,r,求所有n/i(l<=i<=r)的和
思路:水题
 
 
#include <stdio.h>#include <string.h>int main(){int t,n,l,r,sum,i;scanf("%d",&t);while(t--){scanf("%d%d%d",&n,&l,&r);sum = 0;for(i = l;i<=r;i++)sum+=n/i;printf("%d\n",sum);}return 0;}

原创粉丝点击