Codeforces interval a-wasted Time (meaning), codeforces

Source: Internet
Author: User
Tags polyline

Codeforces interval a-wasted Time (meaning), codeforces
A. Wasted Timetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Mr. scrooge, a very busy man, decided to count the time he wastes on all sorts of useless stuff to evaluate the lost profit. he has already counted the time he wastes sleeping and eating. and now Mr. scrooge wants to count the time he has wasted signing papers.

Mr. Scrooge's signature can be represented as a polylineA1A2...AN. Scrooge signs like that: first it places a pen at the pointA1, then draws a segment from pointA1 to pointA2, then he draws a segment from pointA2 to pointA3 and so on to pointAN, Where he stops signing and takes the pen off the paper. at that the resulting line can intersect with itself and partially repeat itself but Scrooge pays no attention to it and never changes his signing style. as Scrooge makes the signature, he never takes the pen off the paper and his writing speed is constant-50 millimeters per second.

Scrooge signed exactlyKPapers throughout his life and all those signatures look the same.

Find the total time Scrooge wasted signing the papers.

Input

The first line contains two integersNAndK(2 cores ≤ CoresNLimit ≤ limit 100, 1 limit ≤ limitKLimit ≤ limit 1000). Each of the followingNLines contains the coordinates of the polyline's endpoints.I-Th one contains coordinates of the pointAI-IntegersXIAndYI, Separated by a space.

All pointsAIAre different. The absolute value of all coordinates does not exceed 20. The coordinates are measured in millimeters.

Output

Print one real number-the total time Scrooges wastes on signing the papers in seconds. The absolute or relative error shocould not exceed 10 seconds-limit 6.

Sample test (s) input
2 10 010 0
Output
0.200000000
Input
5 103 1-5 6-2 -13 210 0
Output
6.032163204
Input
6 105 04 06 03 07 02 0
Output
3.000000000
Question: Give the coordinates of n points, and then use a line on the paper to connect the n points. There is a total of k pieces of paper, and the link speed is 50/second, and the time is used.
Find the total length of the line on a piece of paper, l * k/50 is the time used.
#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include <string>#include <vector>#include <cmath>ausing namespace std;#define LL long longint x[110],y[110];int main(){int n,k;while(scanf("%d %d",&n,&k)!=EOF){double sum=0;for(int i=0;i<n;i++){scanf("%d %d",x+i,y+i);if(i)sum+=(sqrt(pow(x[i]-x[i-1],2)+pow(y[i]-y[i-1],2)));}printf("%.9lf\n",sum*k/50.0);}return 0;}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.