怎么写呢?
  • 板块P1109 学生分组
  • 楼主audvnj
  • 当前回复2
  • 已保存回复2
  • 发布时间2023/7/28 14:49
  • 上次更新2023/11/3 07:13:57
查看原帖
怎么写呢?
996202
audvnj楼主2023/7/28 14:49
#include<bits/stdc++.h>
#define char long long
using namespace std;	
char a,b[51],c,d,l,o;
int main()
{

	cin>>a;
	for(int i=0;i<a;i++)
	{
		cin>>b[i];
		l++;
	}
	cin>>c>>d;
	do{
	for(int i=0;i<l;i++)
	{
		if(b[i]>=d and b[i]<=c)
		{
			cout<<0;return 0;
		}
		if(b[i]>c)
		{
			b[i+1]++;
			o++;
		}
		 else if(b[i]<c)
		{
			b[i+1]--;
			o++;
		}
		
	}
	}while(b[0]>=d and b[0]<=c and b[l]>=d and b[l]<=c);
	if(o==0)cout<<-1;
	cout<<o;
}
2023/7/28 14:49
加载中...