题目链接P1080
这个题目需要玄学的数学证明过程,大家可以参考下洛谷的题解数学证明过程过程
这个题我就不太配写题解了,发下自己的代码
import java.math.BigInteger;
import java.util.*;
public class Main {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
BigInteger a = sc.nextBigInteger();
BigInteger b = sc.nextBigInteger();
king aa[] = new king[n];
BigInteger count = new BigInteger("1");
for(int i = 0;i < n;i++){
aa[i] = new king();
aa[i].a = sc.nextBigInteger();
aa[i].b = sc.nextBigInteger();
}
Arrays.sort(aa);
for(int i = 0;i < n-1;i++)
count = count.multiply(aa[i].a);
if((count.multiply(a).divide(aa[n-1].b)).compareTo(new BigInteger("1")) < 0)
System.out.println(1);
else
System.out.println(count.multiply(a).divide(aa[n-1].b));
}
}
class king implements Comparable{
BigInteger a;
BigInteger b;
public int compareTo(Object b){
king a = (king)b;
if(this.a.multiply(this.b).compareTo(a.a.multiply(a.b)) > 0)
return 1;
if(this.a.multiply(this.b).compareTo(a.a.multiply(a.b)) < 0)
return -1;
else
return 0;
}
}