要合理分析题目难度,不要高估,检查时要检查所有情况,不要只盯着一个地方。
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#include "cstring" #include "stdlib.h" #include "map" #include "string" #include "iostream" #include "set" #include "queue" #include "vector" #define FOP freopen("input.txt","r",stdin) #define Met(x,y) memset(x,y,sizeof x) #define L index*2 #define R index*2+1 using namespace std; typedef long long ll; const ll MAXN=1e6+100; const ll MOD=1e9+7; ll a[MAXN]; int (int argc, char const *argv[]) { ll T_T; cin>>T_T; while(T_T--) { ll n,d; cin>>n>>d; bool a1=1; ll n1=0; for(int i=0;i<n;++i) { scanf("%lld",&a[i]); if(a[i]==1) n1++; } if (d==1) { if (n1==n && n%3==0) { puts("No"); } else { puts("Yes"); } } else { if((n1==n-1 && n%3==0) || (n1==n && (n-1)%3==0) ||(n1==n-1 && (n-1)%3==0)) puts("No"); else puts("Yes"); } } }
|
近期评论