Garlic meter off "rescue" issues

From base camp lifeboat, rescue roof on a number of people back to base camp, the number of roof and roof of the coordinates of each and numbers are entered by the decision, determined to reach the base camp and log all the time spent.

After the origin of the Cartesian coordinate system is the base camp, starting from the base camp every lifeboat, rescue the people who will be sent back to base camp. Point represents the coordinate system of the roof, the roof of each number by its location and its coordinates on the representation.

Every lifeboat from the base camp, at a speed of 50 m / min sail under one roof. After reaching a roof, on which all rescued, each board 111 minutes. Then the boat came back and return to base camp, each disembark 0.50.50.5 minutes. Suppose the origin of a roof with any other connection does not pass through the roof.

Input format
of the first row, an integer representing the number of roof n (1≤n≤100)
followed in order by rows have nnn input, real number represents the first two rows of each roof plane with respect to the coordinate position of Camp (xi, yi) (in meters), and represents a number of integer ri, separated by a space between numbers. 0≤xi, yi ≤100,1 ≤ ri ≤100

Output format
line, the total time required for the rescue, to the minute (rounded up).
For example,
enter
1
30 40 3
output
7
This is my first post transition from C to C ++, and just started to learn C ++, struggling, so the following code will be presented in two languages, C ++ beginners to ease the discomfort
C language

#include <stdio.h>
#include <math.h>
int main()
{
    int r,n,i,T;
    float x,y,t=0;
    scanf("%d",&n);
    for (i=0;i<n;i++)
    {
	scanf("%f %f %d",&x,&y,&r);
	t+=sqrt(x*x+y*y)/50*2+1.5*r;
    }
    T=t;
    if(t-T>0)
    {
        T++;
    }
    printf("%d\n",T);
return 0;
}

C++

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int n,i,r,T = 0;
    float x,y;
    float t = 0;
    cin>>n;
    for(i = 0;i < n;i++)
    {
        cin>>x>>y>>r;
        t+=1.5*r+sqrt(x*x+y*y)/50.0*2;
    }
    T = t;
    if(t-T > 0)
        cout<<T+1;
    else
        cout<<T;
    return 0;
}
Published 27 original articles · won praise 4 · Views 655

Guess you like

Origin blog.csdn.net/qq_45861670/article/details/104409174