异或
题目:https://www.nowcoder.com/acm/contest/87/F
解法:异或为0表示相同,求区间交集长度即可。
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll a,b,c,d,x,y; ll gcd(ll n,ll m) { return n%m?gcd(m,n%m):m; } int main() { while(cin >> a >> b >>c >>d) { y = (d-c+1)*(b-a+1); x = min(b,d) - max(a,c) +1; if(x<0) x = 0; ll g = gcd(x,y); if(x) cout << x/g << '/' << y/g <<endl; else cout << "0/1" <<endl; } return 0; }