Help me in solving EXAMCHTPRIME problem

My issue

check error in this code

My code

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	while(t--){
	    int a,b;
	    cin>>a>>b;
	    int sub=b-a;
	    int count=0;
	    if(a==b){
	        cout<<"-1";
	    }
	    for(int i=1;i*i<=sub;i++){
	        if(sub%i==0){
	            count++;
	        }
	        cout<<count<<endl;
	    }
	}
}

Learning course: Chitkara DSA Bootcamp
Problem Link: CodeChef: Practical coding for everyone

@niyati1137be21
Your logic is not right .
plzz refer the following solution for better understanding .

#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int a,b,count=0;
        cin>>a>>b;
        
        int n=b-a;
        n=abs(n);
        for(int i=1;i<=sqrt(n);i++){
                if(n%i==0){
                    count++;
                    if(i!=n/i)
                    count++;
                }
            }
        cout<<count<<endl;
    }
   
    return 0;
}