关于月赛 B 题
  • 板块学术版
  • 楼主what_else
  • 当前回复10
  • 已保存回复10
  • 发布时间2022/8/7 17:08
  • 上次更新2023/10/27 16:36:08
查看原帖
关于月赛 B 题
539495
what_else楼主2022/8/7 17:08

头一次被 入门 题卡到怀疑人生,谁来帮帮我!(40pts

#include<bits/stdc++.h>
using namespace std;
int a[6];
int b[6];
int t;
bool ch(){
	if(b[1]+1 == b[2] && b[2]+1==b[3] && b[4]==b[5])return 1;
	if(b[1] == b[5] && b[2]+1==b[3] && b[3]+1==b[4])return 1;
	if(b[3]+1 == b[4] && b[4]+1==b[5] && b[1]==b[2])return 1;
	return 0;
}
int main(){
	cin>>t;
	for(int i=1;i<=t;i++){
		for(int j=1;j<=4;j++)
		cin>>a[j];
		bool flag=0;
		for(int j=0;j<=9;j++){
			a[5]=j;
			for(int k=1;k<=5;k++)
			b[k]=a[k];
			sort(b+1,b+5+1);
			if(ch()){
				cout<<1<<endl;
				flag=1;
				break;
			}
		}
		if(!flag)cout<<0<<endl;
	}
}

2022/8/7 17:08
加载中...