D Floor problem(FZU 2104)
来源:互联网 发布:剑雨江湖进阶12数据 编辑:程序博客网 时间:2024/05/17 02:49
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.
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).
For each test case, print the result of f(n,L)+f(n,L+1)+...+f(n,R) in a single line.
31 2 3100 2 100100 3 100
0382332
由于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;}就只有这么多了,没毛病!!
阅读全文
0 0
- D Floor problem(FZU 2104)
- 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 C - Floor problem
- FZU Problem 2104 Floor problem (数学啊 )
- Floor problem
- Floor problem
- Floor problem
- (fzu) Problem D Game(KMP算法,字符串匹配问题)
- FZOJ2104:Floor problem
- FZU Problem 2110 Star (数学啊 )
- FZU Problem 2112 Tickets (dfs 欧拉图)
- (BFS)FZU.Problem 2188 过河I
- FZU 1692 Key problem(循环矩阵)
- MySQL ODBC驱动安装和配置数据源
- C++ 指针、引用、const
- LeetCode #567 Permutation in String
- 初学32的看过来
- HZ偶尔会拿些专业问题来忽悠那些非计算机专业的同学。今天测试组开完会后,他又发话了:在古老的一维模式识别中,常常需要计算连续子向量的最大和,当向量全为正数的时候,问题很好解决。但是,如果向量中包含负数
- D Floor problem(FZU 2104)
- [JavaScript/基础入门二/每天一点点]
- Java的异常处理
- 简单工厂模式
- MR--Configuration
- ios11适配 以及会有的坑
- 欢迎使用CSDN-markdown编辑器
- test
- BOS_页面布局