题目链接;

solution:

根据画图模拟可以知道除第一次纯下降

其余每次都是一半一半的增加

S=h+h+h/2+h/4+h/8+...;

即S=h+2h=3h

#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long ans;
int main() {
	int n;cin>>n;
	for(int i=1;i<=n;i++) {
		int a;
		scanf("%d",&a);
		ans+=a;
		ans%=mod;
	}
	ans=(ans*3)%mod;
	cout<<ans;
}

相关文章:

  • 2021-07-05
  • 2022-12-23
  • 2021-05-12
  • 2021-06-06
  • 2021-06-17
  • 2021-11-12
  • 2021-09-10
  • 2021-09-14
猜你喜欢
  • 2021-07-16
  • 2021-07-03
  • 2022-01-11
  • 2021-07-29
  • 2021-09-19
  • 2021-08-13
  • 2022-12-23
相关资源
相似解决方案