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

//f1 計算有幾個因數

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];//紀錄那個數字的因數數量
    int l, r;
    int max = 0;

    a[0] = 0;

    scanf("%d", &n);

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

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

        while(l <= r){

            a[l] = f1(l);
            if(a[l] > a[max]) max = l;

            l++;
        }
        printf("%d\n", max);
    }
    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.