Created
December 22, 2025 06:45
-
-
Save Mjkim-Programming/0bf41ff3e418525e7515333e193e101d to your computer and use it in GitHub Desktop.
Area of polygon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| double area(vector<int>& x, vector<int>& y) { | |
| int N = x.size(); | |
| ll mulx = 0LL; ll muly = 0LL; | |
| for(int i = 0; i < N; i++) { | |
| mulx += (ll)x[i] * y[(i+1) % N]; | |
| } | |
| for(int i = 0; i < N; i++) { | |
| muly += (ll)x[(i+1) % N] * y[i]; | |
| } | |
| return 0.5 * llabs(mulx - muly); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment