D Floor problem(FZU 2104)
2017-11-25 20:28
302 查看
D Floor problem
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
Sample Output
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
由于C题还没看懂所以先放D题。。。。
题目的意思是:
第一行输入一个整数t,接下来有t组数据
接下来的t行,每行输入三个数n,l,r;令i=l ~ r
求(n/i)整数部分的和。
代码:
#include<stdio.h> #include<algorithm> using namespace std; int main() { int t; scanf("%d",&t); while(t--) { int n,l,r,sum=0; scanf("%d%d%d",&n,&l,&r); for(int i=l;i<=r;i++) sum+=n/i; printf("%d\n",sum); } return 0; }
就只有这么多了,没毛病!!
相关文章推荐
- FZU2104之Floor problem
- FZU 2104 Floor problem(floor)
- FZU Problem 2104 Floor problem (数学啊 )
- FZU Problem 2129 子序列个数
- FZU 2125 Problem 2125 简单的等式
- fzu——Problem 2091 播放器
- FZU Problem 2140 Forever 0.5(计算几何构造,依旧考查思维)
- Simple String Problem FZU - 2218 状压dp
- fzu Problem 2087 统计树边 (kruskal)
- ZOJ Problem Set–2104 Let the Balloon Rise
- FZU:Problem 1864 Christmas Machine
- fzu - 1752 Problem 1752 A^B mod C
- FZU Problem 2151 OOXX Game (数学啊)
- Fzu Problem 2082 过路费 LCT,动态树
- FZU_Problem 2168 防守阵地 I
- FZU 2037 Maximum Value Problem (打表预处理/找规律)
- FZU Problem 2168 防守阵地 I
- FZU Problem 2238 Daxia & Wzc's problem(Lucas定理求组合数)
- FZU Problem 2136 取糖果
- fzu-1753 Another Easy Problem-高速求N!多少个月p