题解:SP16248 NCLNE - Clones
woshizhangchi123 · · 题解
题目大意
鸣人要进行战斗
题目分析
通过题意可以得出,当
此题使用模拟即可。
Code&AC记录
#include<bits/stdc++.h>
#define int long long
using namespace std;
int t,n,people,flag,x;
signed main(){
cin>>t;
while(t--){
cin>>n;
people=flag=1;
while(n--){
cin>>x;
if((people-=x)<0)flag=0;
people*=2;
}
if(flag and !people)cout<<"Yes\n";
else cout<<"No\n";
}
return 0;
}
后记
注意第
if((people-=x)<0)flag=0;
写代码时千万不要将 people-=x 两边的括号去掉,因为 > 的优先级显然高于 -=。