包含快读的题解

__0__  •  4个月前


#include <cstdio>
#include <iostream>
using namespace std;

long long gcd(long long a, long long b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a%b);
}

long long read() {
	char ch;
	ch = getchar();
	long long tem=0, t=1;
	if (!(ch>='0' && ch <= '9')) {
		t=-1;
		ch = getchar();
	}
	for (;ch >= '0' && ch <= '9';ch=getchar()) {
		tem = tem*10+ch-'0';
	}
	return t*tem;
}

int main() {
	long long a, b, n;
	char c;
	cin.tie(0);
	cout.tie(0);
	n = read(); 
	while (n--) {
		a = read();
		b = read();
		cout << (a/(gcd(a, b))) << "/" << (b/(gcd(a, b))) << endl;
	}
	return 0;
} 

Comments: