Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main()
- {
- int casos, routes, check, pcont;
- double rx, ry;
- float **cord;
- while(casos != 0, cin >> casos)
- {
- cord = new float *[casos];
- for(int i=0; i<casos; i++){
- cord[i] = new float[2];
- }
- for(int i=0; i<casos; i++){
- for (int j=0; j<2; j++){
- cin >> cord[i][j];
- }
- }
- cin >> routes;
- for (int i=0; i<routes; i++)
- {
- int *pt;
- double res =0;
- cin >> check;
- pt = new int[check];
- for (int j=0; j<check; j++)
- {
- cin >> pcont;
- pt[j] = pcont;
- }
- for (int k=0; k<check-1; k++)
- {
- double cord_x2 = cord[pt[k+1]][0];
- double cord_x1 = cord[pt[k]][0];
- double w = cord_x2-cord_x1;
- double cord_y2 = cord[pt[k+1]][1];
- double cord_y1 = cord[pt[k]][1];
- double z = cord_y2-cord_y1;
- rx = pow(w,2);
- ry = pow(z,2);
- res += sqrt(rx + ry);
- }
- cout << (int)res << endl;
- delete pt;
- }
- delete cord;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment