Untitled
raw download clone
TEXT
views 23
,
size 537 b
#include<stdio.h>
int index;
int main(){
	int T, L, R, div, factor, ans=0;
	int A[20004];
	scanf("%d", &T);
	for (int i=0; i<T; i++){
		scanf("%d%d", &L, &R);
		 
		for(int j=L; j<=R; j++){
			for(div=1, factor=0; div<=j; div++){
				if(j%div ==0) factor++;
			}
			A[j] = factor; //factor: number of factors
		}
		//printf("%d,%d,%d,%d,%d,%d\n", A[5], A[6], A[7], A[8], A[9], A[10]);
		for(int j=L; j<=R; j++){
			if(A[j]>ans){
			 	ans = A[j];
			 	index = j;
			}
		}
		printf("%d\n", index);	
	}
	return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.