UVa3708 Graveyard (coordinate scaling)

Source: Internet
Author: User

Links: http://acm.hust.edu.cn/vjudge/problem/15133
Analysis: Too good, first the circumference of the circle as 1, evenly distributed n points, and then add m points after a total of (n+m) points, then we put the circumference of the circle to enlarge (n+m), so what good? Is (n+m) the coordinates of a sculpture are all integral points, the corresponding original in the circumference of 1 n points of coordinates from the i/n method (n+m) times, because the sculpture position to move is an integer so we can use rounding to find the nearest whole point (target sculpture position), and then the side length reduced back to 1, In the case of a side length of 1, n sculptures move to the distance of the nearest target sculpture position, the distance of the n-1 point (the No. 0 point does not move) is accumulated and then the distance and equal proportion are enlarged by 10000.

1#include <cstdio>2#include <cmath>3 using namespacestd;4 5 intMain () {6     intN, M;7      while(SCANF ("%d%d", &n, &m) = =2) {8         DoubleAns =0.0;9          for(inti =1; I < n; i++) {Ten             Doublepos = (Double) I * (n + m)/N; OneAns + = Fabs (Pos-floor (pos +0.5))/(n +m); A         } -printf"%.4lf\n", ans *10000); -     } the     return 0; -}

UVa3708 Graveyard (coordinate scaling)

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.