Untitled
raw download clone
C
views 42
,
size 653 b
#include<stdio.h>

//f1 find how many

int f1(int x){

    int ans = 1;
    for(int i = 1; i <= x/2 ; i++){
        if(x % i == 0) ans++;
    }
    return ans;
}

int main(void){

    int n;//n test cases
    int a[20005] = {0};
    int l, r;
    int max = 0;

    scanf("%d", &n);

    for(int i = 0; i < n; i++){

        scanf("%d%d", &l, &r);

        while(l <= r){

            a[l] = f1(l);
            //printf("%d\n", a[l]);

            if(a[l] > a[max]) max = l;
            //else if (a[l] == max || a[l] < a[l-1]) max = l-1;
            l++;
        }
        printf("%d\n", max);
    }
    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.