Help me in solving CHFINVNT problem

My issue

Anyone can check my code why some test case are not passing .

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int N,K,P;
	    cin>>N>>P>>K;
	    int r=P%K;
	    int move=ceil(N/(float)K);
	    int ans=r*move;
	    ans+=(P-r)/K+1;
	    cout<<ans<<endl;
	}
	return 0;
}

Problem Link: CHFINVNT Problem - CodeChef

@mohdkaif123
for test case
1
4 2 3
your code prints
5
and answer should be 4