ferinの競プロ帳

競プロについてのメモ

SRM615 div1 easy AmebaDiv1

考えたこと

Xに含まれないサイズはそのサイズを初期サイズとすれば最終サイズも等しくなるので必ずSに含まれる。Xに含まれるサイズを全て試せばいい。
実装したら通った。ものすごい簡単で逆に驚いた。

// BEGIN CUT HERE
// END CUT HERE
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

map<int, bool> mp;
class AmebaDiv1 {
   public:
   int count(vector <int> X)
  {
    int n = X.size();
    REP(i, n) mp[X[i]] = false;
    for(auto i: mp) {
      int now = i.first;
      REP(j, n) {
        if(now == X[j]) now *= 2;
      }
      if(mp.find(now) != mp.end()) mp[now] = true;
    }
    int ret = 0;
    for(auto i: mp) if(!i.second) ret++;
    return ret;
  }
};