My issue
first test case was passed then received an error of time limit exceed . whats another way?
My code
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t;
cin >> t;
while(t--){
int N,K,x;
cin >> N >> K;
int best_x = 0;
int best_value = 0;
for (int x = 0; x <= N; x++) {
int value = (x % K) * ((N - x) % K);
if (value > best_value) {
best_x = x;
best_value = value;
}
}
cout << best_x << endl;
}
return 0;
}
Problem Link: MAXIMALEXP Problem - CodeChef