Can anyone provide a corner/sample test case for the CHFING(Chef and Ingredient) problem from codechef? I am getting wrong answer when i submit but i am getting the answer correctly for all the test cases that i can come up with.
I have tried finding the pattern with with three conditions
1) N>K
2) N<=K
3) K=1
Is there anything that i am missing?
This is my Code
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ROF(i, a, b) for (int i = a; i >= b; --i)
#define vi vector<int>
using namespace std;
int main()
{
int T;
long long int N, K, MOD = 10e9 + 7;
cin >> T;
while (T--)
{
cin >> N >> K;
if (N < K)
{
cout << (K + abs(K - 1 - N)) % MOD << endl;
}
else if (N >= K)
{
cout << (K - 1) % MOD << endl;
}
else
{
cout << 0 << endl;
}
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire