2012-09-12 10:37:35Morris

[TopCoder][SRM553] PlatypusDuckAndBeaver

看了題解之後就慚愧了 ... 我只是發布來自己看得, 別虐 ...


#include<iostream>
#include<map>
#include<math.h>
#include<vector>
#include<string>
#include<string.h>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<sstream>
#define all(X) (X).begin(),(X).end()
#define mem(X) memset(X,0,sizeof(X))
#define debug_v(v) for(int db=0;db<(v).size();db++)cout<<v[db]<<','<<;cout<<endl;
#define pqpush(pq,x,cmp) (pq).push_back(x);push_heap((pq).begin(),(pq).end(),cmp);
#define pqpop(pq,cmp) pop_heap((pq).begin(),(pq).end(),cmp);(pq).pop_back();
#define PB(x) push_back(x)
using namespace std;
typedef long long ll;
typedef vector<int>::iterator iv;
typedef map<string,int>::iterator msii;
typedef map<int,int>::iterator miii;
typedef map<int,bool>::iterator mibi;
typedef map<string,bool>::iterator msbi;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef map<int,bool> mib;
typedef map<string,bool> msb;
typedef vector<int> vi;
typedef vector<string> vs;


class PlatypusDuckAndBeaver
{
    public:
        int minimumAnimals(int a, int b, int c) {
            int d = -2;
            int dx = a - 4*c - 2*b;
            int dy = 4*c - a;
            int dz = 2*c + 2*b - a;
            return dx / d + dy / d + dz / d;
        }
};