i am having time limit exceeded error,can someone pls help
#include
using namespace std;
int main()
{
int t;
int p;
cin>>t;
int s;
int n;
while(t>0)
{
scanf("%d %d",&s,&n);
p=0;
if( s==1)
{
printf("1");
printf("\n");
t--;
continue;
}
while(s>0 && n>=2)
{
p=p+s/n;
s=s%n;
n=n-2;
}
if( s>0)
{
p=p+s/1;
}
printf("%d",p);
t--;
}
return(0);
}