luogu P1080国王游戏
Posted eric-walker
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了luogu P1080国王游戏相关的知识,希望对你有一定的参考价值。
贪心加高精
传送门:QWQ
先考虑两个人
a0 | b0 | |
---|---|---|
p1 | a1 | b1 |
p2 | a2 | b2 |
那么满足:(huge ans1=max(frac{a0}{b1} , frac{a0a1}{b2}))
a0 | b0 | |
---|---|---|
p2 | a2 | b2 |
p2 | a1 | b1 |
(huge ans2=max(frac{a0}{b2} , frac{a0a2}{b1}))
如果要让ans1<ans2
设 (k1=frac{a0}{b1} , k2=frac{a0a1}{b2} , k3=frac{a0}{b2} , k4=frac{a0a2}{b1})
则 k1< k4
k2 > k3
如果要让ans1
展开,得:(frac{a0a2}{b1} > frac{a0a1}{b2})
移项得:(a1b1<a2b2)
根据冒泡排序
两个相邻交换一定使答案更差
所以可以根据ab的大小排序(下标排序)
然后就是麻烦的高精了
//自动无视c++14
// luogu-judger-enable-o2
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e4+5;
int n;
// The MIT License (MIT)
// Copyright (c) YEAR NAME
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
struct big{
static const int base=10000;
int a[2333];
int len;
big(){memset(a,'