大佬们帮帮忙
查看原帖
大佬们帮帮忙
739640
Handsome_Brother_Boy楼主2024/5/29 13:59

题目

#include<bits/stdc++.h>
using namespace std;
long long n,a[55],t,f,s;
int main(){
	cin>>t;
	for(int j=1;j<=t;j++)
	{
		f=0;
		s=0;
		cin>>n;
		for(int i=1;i<=n;j++)
		{
			cin>>a[i];
		}	
		for(int i=n;i>=2;i--)
		{
			if(a[i]==0)
			{
				f=1;
				break;
			}
			if(a[i]<=a[i-1])
			{
				while(a[i]<=a[i-1])
				{
					a[i-1]/=2;
					s++;
				}
			}
		}
		if(f==0)
		{
			cout<<s<<endl;
		}
		else
		{
			cout<<"-1"<<endl;
		}
	}
	return 0;
}

哪错了?求调

2024/5/29 13:59
加载中...