求助
查看原帖
求助
363006
wangyibo201026楼主2021/12/1 20:19

RT, 代码:

#include<bits/stdc++.h>

using namespace std;

long long n, a[100005], sum;
bool f;

void Solve(){  
  while(cin >> n){
    if(n == 0){
      return ;
    }
    if(!f){
      f = true;
    }
    else{
      cout << endl;
    }
    long long ans = 0;
    for(int i = 1; i <= n; i++){
      cin >> a[i];
      sum += a[i];
      ans += abs(sum);
    }
    cout << ans;
  }
}

int main(){
  Solve();
  return 0;
}
2021/12/1 20:19
加载中...