宇月幸成


私信TA

用户名:3350680655

访问量:13771

签 名:

题解都沉没在OJ里了..

等  级
排  名 401
经  验 4906
参赛次数 1
文章发表 47
年  龄 24
在职情况 学生
学  校
专  业 软件工程

  自我简介:

刷题打发时间,没别的事做了

 

0.0分

2 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

#include<iostream>
#include<math.h>
typedef long long ll; 
using namespace std;
 
int main (){
	int n;int j=1;
	cin>>n;
	int num[n];ll max=0;
	for( int i=0;i<n;i++){
		cin>>num[i];
		//cout<<num[i];
	}
			int sum=0;//行 
			while (n){
				
				n=n/2;
				sum++;
				
				
			}
		int b=0;int hang=0; 
for(int j=1;j<=sum;j++){
	ll count=0;
	int m=pow(2,j-1);
	if(j==sum){
	
	m=n+1-pow(2,j-1);} 
	for(int k=0;k<m;k++){
		
		count=count+num[b];
	
		b++;
			
	}
			if(count>max){
			
			max=count;
			hang=j;
			
			
			} 
	
}
	cout<<hang<<endl<<max;
	
	return 0;
} 
大佬们看看这为啥不对啊,渴求大佬指导
2021-04-05 20:40:18
  • «
  • 1
  • »