Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream cin("maxd.in");
- ofstream cout("maxd.out");
- int main()
- {
- int a, b, divm = 1e9, ctdiv = 0, nrdivM = -1;
- cin >> a >> b;
- for(int i = a; i <= b; ++i)
- {
- int q = i, nrdiv = 1, p = 0, d = 3;
- while(q % 2 == 0)
- {
- ++p;
- q /= 2;
- }
- if(p) nrdiv *= (p + 1);
- while(q != 1)
- {
- p = 0;
- while(q % d == 0)
- {
- ++p;
- q /= d;
- }
- if(p) nrdiv *= (p + 1);
- d += 2;
- if(d * d > q) d = q;
- }
- if(nrdiv > nrdivM)
- {
- nrdivM = nrdiv;
- divm = i;
- ctdiv = 1;
- }
- else if(nrdiv == nrdivM)
- {
- if(i < divm) divm = i;
- ++ctdiv;
- }
- }
- cout << divm << " " << nrdivM << " " << ctdiv;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement