FZU 2104 C - Floor problem
2014-11-23 21:13
393 查看
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
题意:
利用floor就可以;
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
题意:
利用floor就可以;
#include <cmath> #include <iostream> #include <cstdio> using namespace std; int main () { int T; int n,l,r; scanf("%d",&T); while (T--) { scanf("%d%d%d",&n,&l,&r); int sum = 0; for (int i = l; i <= r; i++) { sum += floor(n/i); } printf("%d\n",sum); } }
相关文章推荐
- FZU 2104 Floor problem(floor)
- FZU - 2104 Floor problem
- fzu 2104 Floor problem(水题)
- FZU Problem 2104 Floor problem (数学啊 )
- FZU 2104 Floor problem(水题)
- FZU 2104 Floor problem
- FZU 2104 Floor problem (水题)
- FZU 2104 (13.11.28)
- FZU Problem 2104 Floor problem
- FZU 2104 (13.11.28)
- D Floor problem(FZU 2104)
- FZU2104之Floor problem
- FZU 1492 地震预测(模拟链表)(技巧题)
- fzu 2107 Hua Rong Dao
- poj2104 K-th Number
- fzu 2171 防守阵地 II(线段树 区间更新)
- poj 2104(主席树)
- FZU 2129 子序列个数(计数DP)
- (平方分割)POJ 2104 K-th Number
- FZU 2234 牧场物语【Dp】好题!好题!