← Back to topics
Topic

Delioci:TLE

V
Vidakovic
can somebody tell me how to make my code faster
# include <iostream>
using namespace std;
int b,i,j,bd,m,broj;
main ()
{
cin>>b;
m=0;
for (i=1;i<=b;i++){
bd=1;
for (j=1;j<=(i/2);j++)
if ((i%j)==0) bd++;
if (bd>m) {m=bd;broj=i;}
}
cout<<broj<<endl;
cout<<m<<endl;

}
A
Amtrix
Well with that idea you can't pass the task.
Search in forum, i think there is explained how to solve the problem ;)