My issue
i’m checking the condition if(A+(A-B)*(K-1)>=H) and increasing count, in two for loops what is wrong in this.
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--){
long long N, K, H;
cin >> N >> K >> H;
long long count = 0;
for (long long A = 1; A <= N; ++A) {
for (long long B = 1; B<= A; ++B) {
if(A+(A-B)*(K-1)>=H) count++;
}
}
cout<<count<<endl;
}
}
Problem Link: Amphibian Escape Practice Coding Problem