题解 CF1221A 【2048 Game】

其实代码挺简单,不过用了1.67s,呜啊

代码有注释

#include <iostream>
using namespace std;

int main()
{
	int n, m, sum = 0;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
	    sum = 0;//每次都要变回0
	    cin >> m;
	    int x;
	    for(int j = 1; j <= m; j++)
	    {
	        cin >> x;
	        if(x > 2048)//比2048大不累加
	        {
	            continue;
	        }
	        sum += x;
	    }
	    if(sum >= 2048)//如果结果大于等于2048,那么因为数都是2的n次方,肯定能组成2048的
        {
            cout << "YES\n";
        }
	    else //否则no
	    {
	        cout << "NO\n";
	    }
	}
	return 0;
}
posted @ 2020-10-02 18:05  HappyBobb  阅读(5)  评论(0)    收藏  举报  来源