FZU 2104 (13.11.28)

2014-11-24 02:54:31 · 作者: · 浏览: 1
Problem 2104 Floor problem

Accept: 376 Submit: 433
Time Limit: 1000 mSec Memory Limit : 32768 KB

\ Problem Description

In this problem, we have f(n,x)=FloZ http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vcltuL3hdLiBIZXJlIEZsb29yW3hdIGlzIHRoZSBiaWdnZXN0IGludGVnZXIgc3VjaCB0aGF0IG5vIGxhcmdlciB0aGFuIHguIEZvciBleGFtcGxlLCBGbG9vclsxLjFdPUZsb29yWzEuOV09MSwgRmxvb3JbMi4wXT0yLjwvcD4KPHA+WW91IGFyZSBnaXZlbiAzIHBvc2l0aXZlIGludGVnZXJzIG4sIEwgYW5kIFIuIFByaW50IHRoZSByZXN1bHQgb2YgZihuLEwpJiM0MztmKG4sTCYjNDM7MSkmIzQzOy4uLiYjNDM7ZihuLFIpLCBwbGVhc2UuPC9wPgoKPGgyPjxpbWcgc3JjPQ=="https://www.cppentry.com/upload_files/article/49/1_6pr05__.gif" alt="\"> 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

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


为高教杯复习而做,水题

直接贴AC代码:
#include
  
   

int f(double x) {
    int i;
    for(i = 0; i <= 10000; i++)
        if(x >= i && x < i+1)
            break;
    return i;
}

int main() {
    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++) {
            double num = n / i;
            sum += f(num);
        }
        printf("%d\n", sum);
    }
    return 0;
}