码迷,mamicode.com
首页 > 其他好文 > 详细

Educational Codeforces Round 73 (Rated for Div. 2) A. 2048 Game

时间:2019-10-05 16:09:14      阅读:90      评论:0      收藏:0      [点我收藏+]

标签:insert   wap   test   pow   --   each   sum   https   form   

链接:

https://codeforces.com/contest/1221/problem/A
题意:
You are playing a variation of game 2048. Initially you have a multiset s of n integers. Every integer in this multiset is a power of two.

You may perform any number (possibly, zero) operations with this multiset.

During each operation you choose two equal integers from s, remove them from s and insert the number equal to their sum into s.

For example, if s={1,2,1,1,4,2,2} and you choose integers 2 and 2, then the multiset becomes {1,1,1,4,4,2}.

You win if the number 2048 belongs to your multiset. For example, if s={1024,512,512,4} you can win as follows: choose 512 and 512, your multiset turns into {1024,1024,4}. Then choose 1024 and 1024, your multiset turns into {2048,4} and you win.

You have to determine if you can win this game.

You have to answer q independent queries.

思路:

将不大于2048的加起来判断

代码:

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int t, a, b, c;
    cin >> t;
    while (t--)
    {
        cin >> a >> b >> c;
        if (a < b)
            swap(a, b);
        c += (a-b);
        a = b;
        int sum = min(a, c);
        a -= sum, b -= sum, c -= sum;
        cout << sum+(a+b)/3 << endl;
    }

    return 0;
}

Educational Codeforces Round 73 (Rated for Div. 2) A. 2048 Game

标签:insert   wap   test   pow   --   each   sum   https   form   

原文地址:https://www.cnblogs.com/YDDDD/p/11624799.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!