1 solutions

  • 0
    @ 2025-12-3 17:21:29

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    long long p,q;
    int main()
    {
    	cin>>p>>q;
    	long long cha=abs(p-q);
    	if(cha==1 || p>q) {
    		cout<<-1;return 0;
    	}
    	long long ans=cha/2;
    	cout<<ans;
    	
    	return 0;
    }
    
    • 1

    Information

    ID
    991
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    1
    Accepted
    1
    Uploaded By