本题不能使用 __int128 吗?
查看原帖
本题不能使用 __int128 吗?
804607
rainygame楼主2023/4/1 12:43

蒟蒻懒得写高精,所以就用了 __int128,但是 60pts……

#include <bits/stdc++.h>
using namespace std;
#define int __int128

int uread(){
	int x(0);
	char ch;
	while ((ch = getchar()) < 48);
	do{
		x = (x << 1) + (x << 3) + (ch ^ 48);
	}while ((ch = getchar()) > 47);
	return x;
}

void uprint(int x){
	int tmp = x/10;
	if (tmp) uprint(tmp);
	putchar(x-(tmp<<1)-(tmp<<3)+'0');
}

int n, ans, mul;

struct Peo{
	int a, b;
}people[1001];

bool cmp(Peo a, Peo b){
	return a.a * a.b < b.a * b.b;
}

signed main(){
	n = uread();
	for (int i=0; i<=n; i++){
		people[i].a = uread();
		people[i].b = uread();
	}
	sort(people+1, people+n+1, cmp);
	
	mul = people[0].a;
	for (int i=1; i<=n; i++){
		ans = max(ans, mul/people[i].b);
		mul *= people[i].a;
	}
	
	uprint(ans);
	
	return 0;
}

2023/4/1 12:43
加载中...