This solution is wrong. Try with N = 100 and K = 7. Your solution will give answer as 2, but the correct answer is 4 (which is 100%6).
The testdata has been updated to include this now.
This solution is wrong. Try with N = 100 and K = 7. Your solution will give answer as 2, but the correct answer is 4 (which is 100%6).
The testdata has been updated to include this now.
The testdata has been updated to include this now.
SAVAGE !!! LOL
Why is my code wrong?
#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
for(int i=0; i<t; i++)
{
int n,k;
cin >> n >> k;
int q,r;
for(int j=1; j<=n+1; j++)
{
if(k>n/j)
{
q = (n/j)+1;
r = n%q;
break;
}
}
cout << r << endl;
}
}
I also did N%K at first ā¦
but actuallyā¦
K IS NOT the no. of people Tuzik calledā¦
K IS MAX no. of people Tuzik CAN CALL .
So, find out max no. of coins our puppy can have,keeping in mindā¦ K, may or may not be the no. of people he actually called where min. value for K is 1(cz dogs canāt open a wooden chest!!.. LOL)
Moral: READ Questions CAREFULLY.
HAPPY CODING