Floor problem

Floor 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

31 2 3100 2 100100 3 100

Sample Output

0382332
//水題
#include<stdio.h>
int r,s;
int fun(int n,int l)
{
  if(l==r) return s+n/r;
   s+=n/l;
  return fun(n,l+1);
}
int main()
{
int t,n,l;
 while(scanf("%d",&t)!=EOF)
 {
   while(t--)
   {
             s=0;
      scanf("%d%d%d",&n,&l,&r);   
        printf("%d\n",fun(n,l));  
   }                          
 }
return 0;
}


發佈了90 篇原創文章 · 獲贊 2 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章