Floor problem
来源:互联网 发布:佳成餐饮软件 编辑:程序博客网 时间:2024/06/05 18:14
Problem C Floor problem
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
#include <stdio.h>
#include <iostream>
using namespace std;
int floor (int a,int b)
{
return int (a/b);
}
int main ()
{
int n,l,r,t,i,sum=0;
while( scanf("%d",&t)!=EOF)
{
while(t--)
{ sum=0;
scanf("%d %d %d",&n,&l,&r);
for(i=l;i<=r;i++)
{
sum+=floor(n,i);
}
printf("%d\n",sum);
}
}
return 0;
}
- Floor problem
- Floor problem
- Floor problem
- FZOJ2104:Floor problem
- FZU 2104 Floor problem
- FZU - 2104 Floor problem
- FZU Problem 2104 Floor problem
- FZU 2104 Floor problem(floor)
- FZU 2104 C - Floor problem
- fzu 2104 Floor problem(水题)
- FZU 2104 Floor problem(水题)
- D Floor problem(FZU 2104)
- FZU Problem 2104 Floor problem (数学啊 )
- floor
- floor () 函数
- Math.floor
- Math.floor
- floor函数
- [python] spider 01
- H.264参考软件JM12.2RC代码详细流程
- 【Cocos2dx隐藏iOS7状态栏】通过添加Plist Key隐藏iOS7状态栏
- 题目1506:求1+2+3+...+n
- uboot编译过程完全分析
- Floor problem
- 2014腾讯校招面试之一总结
- VC++程序常见错误 提示(1)---gyy整理
- 温故而知新之异常处理
- 常用linux命令列表
- C++循环链表实现约瑟夫问题
- 插入算法-insertionsort
- Android之底部導航欄--RadioGroup、TabHost、Fragment
- openstack oslo代码分析