#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
long long int n,k,count,sum,i,j;
cin>>n>>k;
while(n!=-1 && k!=-1){
count = 0;
sum = (n*(n-1))/2;
for(i=1;i<=n;i++){
for(j=1;j<=n;j++){
if(j!=i && (j+i)<=k){
count++;
}
}
}
int fact = __gcd(count,sum);
count = count/fact;
sum = sum/fact;
cout<<count<<"/"<<sum<<endl;
cin>>n>>k;
}
return 0;
}
The output should be:
0/1
2/2475
2/15
But my output is:
0/1
4/2475
4/15
link to the problem: SPOJ.com - Problem BALLSUM