Fzu problem 2104 Floor problem (math AH)

Source: Internet
Author: User

Title Link: 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] are 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 the test cases.

Then T-cases, for any case, only 3 integers n, l and R (1≤n, L, r≤10,000, L≤r).

Outputfor each test case, print the result of f (n,l) +f (n,l+1) +...+f (n,r) in a single line. Sample INPUT31 2 3100 2 100100 3 sample Output0382332 Source "Higher Education Cup" the third Fujian University student Program Design Contest


The code is as follows:

#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;}



Fzu problem 2104 Floor problem (math AH)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.