We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 80db972 commit fce56adCopy full SHA for fce56ad
24000/24533/24533.cpp
@@ -0,0 +1,25 @@
1
+#include <bits/stdc++.h>
2
+using namespace std;
3
+
4
+typedef long long ll;
5
6
+#define FOR(i, a, b) for (int i = a; i < b; i++)
7
+int N;
8
+ll a, b, c, d, ans=0;
9
10
+// energy generation satisfies commutivity and associativity
11
+int main() {
12
+ ios::sync_with_stdio(false); cin.tie(NULL);
13
+ cin>>N;
14
+ cin>>a>>b;
15
+ FOR(i, 1, N){
16
+ cin>>c>>d;
17
+ ans += a*d+b*c;
18
+ a+=c;
19
+ b+=d;
20
+ }
21
22
+ cout<<ans;
23
24
+ return 0;
25
+}
0 commit comments