Skip to content

Instantly share code, notes, and snippets.

@Acarus
Created March 30, 2017 08:58
Show Gist options
  • Save Acarus/e5a21cfe3131b92264f9ff4b0fdf4661 to your computer and use it in GitHub Desktop.
Save Acarus/e5a21cfe3131b92264f9ff4b0fdf4661 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b) {
return !b ? a : gcd(b, a % b);
}
int main(int argc, char **argv) {
ios::sync_with_stdio(false);
srand(time(0));
while (true) {
ll n, k;
cin >> n >> k;
if (n == -1 && k == -1) break;
ll a = 0;
for (ll i = 1; 2*i <= k; ++i) a += k - 2*i;
ll b = n*(n-1)/2;
ll ggcd = gcd(a, b);
if (a == 0) cout << 0 << endl;
else if (a == b) cout << 1 << endl;
else cout << a/ggcd << "/" << b/ggcd << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment