zoukankan      html  css  js  c++  java
  • FZU 2104 Floor problem (水

    Floor problem
    Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

    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

    3
    1 2 3
    100 2 100
    100 3 100
    

    Sample Output

    0
    382
    332


    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <algorithm>
    #include <queue>
    #include <vector>
    #include <iomanip>
    #include <math.h>
    #include <map>
    using namespace std;
    #define FIN     freopen("input.txt","r",stdin);
    #define FOUT    freopen("output.txt","w",stdout);
    #define INF     0x3f3f3f3f
    #define INFLL   0x3f3f3f3f3f3f3f
    #define lson    l,m,rt<<1
    #define rson    m+1,r,rt<<1|1
    typedef long long LL;
    typedef pair<int,int> PII;
    
    int main()
    {
        //FIN
        int T;
        scanf("%d", &T);
        while(T--){
            int n, l, r;
            int sum = 0;
            scanf("%d%d%d", &n, &l, &r);
            for(int i = l; i <= r; i ++){
                sum += n / i;
            }
            printf("%d
    ", sum);
    
        }
    
    }
    

      

  • 相关阅读:
    使用fiddler2抓取手机发出的请求信息
    HTML转义字符集合
    spm3安装和使用
    JSP
    Servlet
    Struts2
    java多线程-消费者和生产者模式
    java异常处理机制(try-catch-finally)
    java内部类
    java上转型和下转型(对象的多态性)
  • 原文地址:https://www.cnblogs.com/Hyouka/p/5790899.html
Copyright © 2011-2022 走看看