I have a problem on coderforces that called divisors.
I believe that I had solved it, but it gives me a time limit exceeded error so I had tried my best to make it shorter but still the same error.
In the problem I have to give how many divisors the number should have.
My code is:
#include <iostream>
using namespace std;
int main(){
long long t, x;
int res = 2;
cin >> t;
for (int j = 0; j < t; j++){
cin >> x;
for (int i = 2; i <= x / 2; i++){
if (x%i == 0){
res++;
}
}
cout << res << endl;
}
return 0;
}
Example input should be:
3
12
7
36
The output should be:
6
2
9