Question
#include using namespace std; string ltrim(const string &); string rtrim(const string &); /* * Complete the 'divisors' function below. * * The function is expected
#include
using namespace std;
string ltrim(const string &);
string rtrim(const string &);
/*
* Complete the 'divisors' function below.
*
* The function is expected to return an INTEGER.
* The function accepts INTEGER n as parameter.
*/
int divisors(int n) {
}
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
string t_temp;
getline(cin, t_temp);
int t = stoi(ltrim(rtrim(t_temp)));
for (int t_itr = 0; t_itr
string n_temp;
getline(cin, n_temp);
int n = stoi(ltrim(rtrim(n_temp)));
int result = divisors(n);
fout
}
fout.close();
return 0;
}
string ltrim(const string &str) {
string s(str);
s.erase(
s.begin(),
find_if(s.begin(), s.end(), not1(ptr_fun
);
return s;
}
string rtrim(const string &str) {
string s(str);
s.erase(
find_if(s.rbegin(), s.rend(), not1(ptr_fun
s.end()
);
return s;
}
Watson gives an integer N to Sherlock and asks him: What is the number of divisors of N that are divisible by 2?. Input Format First line contains T, the number of testcases. This is followed by T lines each containing an integer N. Output Format For each testcase, print the required answer in one line. Constraints 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started