If this is a Codechef problem, you should know that the Codechef adjudicators are aware of this forum, and that people use it to cheat on their contests. If you use this forum to try and cheat, you run the risk of being disqualified.
1 2 3 4 5
for ( size_t n = minN; n <= maxN; ++n ) {
for ( size_t k = minK; k <= maxK and k * 2 < n; ++k ) {
std::cout << "N=" << n << " K=" << k << " Answer=42\n";
}
}
That should cover most, although the answer might be debatable.