← Back to List

13226번: Divisors Again ↗

Solutions

C++14
520 B | 520 chars
#include <iostream>
using namespace std;
int T;
int L,R,ans,cnt;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> T;
    while(T--) {
        cin >> L >> R;
        ans = 0;
        cnt = 0;
        for(int x=L; x<=R; x++) {
            cnt = 0;
            for(int y =1; y*y<=x; y++) {
                if(x%y == 0) {
                    cnt++;
                    if(y*y != x) cnt++;
                }
            }
            if(ans < cnt) ans = cnt;
        }
        cout << ans << "\n";
    }
}