2018 BACS Regional Programming Contest C. BACS, Scoundrel Shopkeeper and Contiguous Sequence (模擬)

chr1st0pher發表於2020-11-17

Description在這裡插入圖片描述
Solution

模擬

Code

const int maxn = 1e2 + 7;
int a[maxn];
int main() {
	int T;scanf("%d",&T);
	for(int cas = 1;cas <= T;++cas) {
		int n,m;scanf("%d %d",&m,&n);
		ll sum = 0;
		for(int i = 1;i <= n;++i) {
			scanf("%d",&a[i]); sum += a[i];
		}
		bool flag1 = false, flag2 = false;
		if(sum == m) flag1 = true;
		for(int i = 1;i < n;++i) {
			if(a[i+1] - a[i] == 1) {flag2 = true; break;}
		}
		printf("Case %d: Thank You BACS!!!", cas);
		if(flag1) printf(" Thik ache."); else printf(" Bojjat dokandar!!");
		if(flag2) printf(" Yes\n"); else printf(" No\n"); 
	}
}

相關文章