FZU Problem 2104 Floor problem (数学啊 )

题目链接:http://acm.fzu.edu.cn/problem.php?pid=2104

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

Source

“高教社杯”第三届福建省大学生程序设计竞赛

代码如下:

#include <cstdio>
#include <cmath>
int main()
{
    int t;
    int n, l, r;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d%d",&n,&l,&r);
        double sum = 0;
        for(int i = l; i <= r; i++)
        {
            sum+=floor(n*1.0/i);
        }
        printf("%.0lf\n",sum);
    }
    return 0;
}
时间: 2024-10-15 20:37:23

FZU Problem 2104 Floor problem (数学啊 )的相关文章

FZU 2104 Floor problem (水

Floor problem Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u FZU 2104 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

fzu 1753 Another Easy Problem

本题题意为求 t (t<150) 个 c (n,m)  (1<=m<=n<=100000)的最大公因子: 本题的难点为优化.主要有两个优化重点.一是每次对单个素因子进行处理,优化每次的数组清零:二是对求阶乘素因子个数的优化 ei=[N/pi^1]+ [N/pi^2]+ …… + [N/pi^n]  其中[]为取整 ei 为数 N!中pi 因子的个数: #include <iostream>#include <cstring>#include <cmat

贪心 FZU 2013 A short problem

题目传送门 1 /* 2 题意:取长度不小于m的序列使得和最大 3 贪心:先来一个前缀和,只要长度不小于m,从m开始,更新起点k最小值和ans最大值 4 */ 5 #include <cstdio> 6 #include <algorithm> 7 using namespace std; 8 9 const int MAXN = 1e6 + 10; 10 const int INF = 0x3f3f3f3f; 11 int a[MAXN], sum[MAXN]; 12 13 in

NYOJ219 An problem about date 【数学】

An problem about date 时间限制:2000 ms  |  内存限制:65535 KB 难度:2 描述 acm的iphxer经常忘记某天是星期几,但是他记那天的具体日期,他希望你能写个程序帮帮他. 输入 每行有三个整数 year,month,day,日期在1600年1月1日到9600年1月1日之间; 输出 输出对应的星期,用一个整数表示;(星期一到星期六用1-6表示,星期日用0表示) 样例输入 2011 3 6 1949 10 1 2011 4 1 1945 8 15 样例输出

FZU Problem 1692 Key problem(循环矩阵)

循环矩阵,这里有解说:http://wenku.baidu.com/link? url=zcJ-sxrj0QDqzz8xCnHTnB7gxjoNRyOZzS4_4ZA22c8Bs9inYn6vVkqTVr_w-riLa8oRnYA9SRcCZ9f4UciCUNGeNAG4dCGclYRPS18YLGa 推出第一层以下依据性质就能够得到. Problem 1692 Key problem Accept: 144    Submit: 663 Time Limit: 1000 mSec    Mem

ubuntu:solve the problem of &#39;E:Problem with MergeList /var/lib/apt/lists/&#39;

just run this command: sudo rm /var/lib/apt/lists/* -vfR it will remove all the software package with the state of 'apt-get install' and no use to leave them, that's ok to just r.m. other conditons can refer to this article:http://blog.csdn.net/gopai

Codeforces Gym 100342D Problem D. Dinner Problem Dp+高精度

Problem D. Dinner ProblemTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attachments Description A group of k students from Cooking University living in the campus decided that each day of the semester one of them will p

FZU Problem 2110 Star (数学啊 )

题目链接:http://acm.fzu.edu.cn/problem.php?pid=2110 Problem Description Overpower often go to the playground with classmates. They play and chat on the playground. One day, there are a lot of stars in the sky. Suddenly, one of Overpower's classmates ask

FZU 2215 Simple Polynomial Problem (多项式乘法 栈)

Problem 2215 Simple Polynomial Problem Time Limit: 1000 mSec    Memory Limit : 32768 KB Problem Description You are given an polynomial of x consisting of only addition marks, multiplication marks, brackets, single digit numbers, and of course the le