Codeforces 127A-Wasted Time(題意),codeforces

來源:互聯網
上載者:User

Codeforces 127A-Wasted Time(題意),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 polyline A1A2... An. Scrooge signs like that: first it places a pen at the point A1, then draws a segment from point A1 to point A2, then he draws a segment from point A2 to point A3 and so on to point An, 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 exactly k papers 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 integers n and k (2 ≤ n ≤ 100, 1 ≤ k ≤ 1000). Each of the following n lines contains the coordinates of the polyline's endpoints. The i-th one contains coordinates of the point Ai — integers xi and yi, separated by a space.

All points Ai are 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 should not exceed 10 - 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
題意:給n個點的座標,然後在紙上用折線將這n個點連起來,一共有k張紙,連線速度為50/second ,求所用時間。
求出在一張紙上的連線的總長l,l*k/50 即所用時間。
#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;}



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.