Skip to content

Commit

Permalink
Update 1104. Sum of Number Segments (20).cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchuo committed Jun 18, 2020
1 parent 6de3461 commit 2984d78
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions AdvancedLevel_C++/1104. Sum of Number Segments (20).cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ using namespace std;
int main() {
int n;
cin >> n;
double sum = 0.0, temp;
long long sum = 0;
double temp;
for (int i = 1; i <= n; i++) {
cin >> temp;
sum = sum + temp * i * (n - i + 1);
sum += (long long)(temp * 1000) * i * (n - i + 1);
}
printf("%.2f", sum);
printf("%.2f", sum / 1000.0);
return 0;
}

0 comments on commit 2984d78

Please sign in to comment.