[NOIP 2012] 킹덤 게임 고정밀+욕심

5952 단어 NOIP

코드

#include 
#include 
#include 
#include 
using namespace std;
typedef long long ll;
const int maxn = 1000 + 2, Len = 4000 + 1, base = 10000;

struct Holder{
    int l,r;
}p[100000];

int cmp(Holder a,Holder b){
    return a.l*a.rstruct Bign{
    int len;
    int v[Len];
    Bign(int r = 0) {for (len = 0; r > 0; r /= base) v[len++] = r % base;}
    Bign &operator = (const Bign &a){
        memcpy(this, &a, sizeof(int) * (a.len + 1));
        return *this;
    }
    bool operator < (const Bign &a){
        if (len != a.len) return len < a.len;
        for (int i = len - 1; i >= 0; i--)
            if (v[i] != a.v[i]) return v[i] < a.v[i];
        return false;
    }
}temp,res,ans;

ostream &operator << (ostream &out, const Bign &a){
    printf("%d", a.len == 0 ? 0 : a.v[a.len - 1]);
    for (int i = a.len - 2; i >= 0; i--) printf("%04d", a.v[i]);
    return out;
}
Bign operator * (const Bign &a, const int &b){
    Bign ans = 0;
    if (!a.len || !b) return ans;
    int carry = 0, i;
    for (i = 0; i < a.len || carry; i++){
        if (i < a.len) carry += a.v[i] * b;
        ans.v[i] = carry % base;
        carry /= base;
    }
    ans.len = i;
    return ans;
}
Bign operator / (const Bign &a, const int &b){
    Bign ans = a;
    int carry = 0;
    for (int i = ans.len - 1; i >= 0; i--){
        ans.v[i] += carry * base;
        carry = ans.v[i] % b;
        ans.v[i] /= b;
    }
    while (!ans.v[ans.len - 1] && ans.len) ans.len--;
    return ans;
}

int n;

int main() {
    scanf("%d",&n);
    scanf("%d%d",&p[0].l,&p[0].r);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&p[i].l,&p[i].r);
    }   
    sort(p+1,p+1+n,cmp);
    res=p[0].l;
    for(int i=1;i<=n;i++){
        temp=res/p[i].r;
        if(anscout<return 0;
}

좋은 웹페이지 즐겨찾기