i don’t know whats wrong with my code ???
it do pass the test cases …(thanks in advance)
#include <iostream>
#include <algorithm>
using namespace std;
long long int greed(long long int n,long long int k){
long long int maxi=0;
for(long long int i=1;i<=k;i++){
maxi=(maxi,n%k);
}
return maxi;
}
int main() {
// your code goes here
int n;
cin>>n;
while(n--){
long long int n,k;
cin>>n>>k;
cout<<greed(n,k)<<endl;
}
return 0;
}