Round 1 of the 5th C++ Special Selection Competition for Primary and Secondary Schools in Putian: T1 – Distance to the Sun

Problem Description

In the era of interstellar exploration, humanity has launched the “Solar Walk” program! Astronauts, equipped with high-tech walking gear, take a stable step of 1 meter every second. The distance from Earth to the Sun is a constant 1.5×10^11 meters, and the length of each step is set by the equipment parameters as an integer a meters. You are required to write a program to accurately calculate how many years it would take to “walk” from Earth to the Sun at the current step length, with the result rounded to two decimal places.

Input Format

Input a positive integer a, representing the length of each step (in meters).

Output Format

Output a floating-point number t, representing the number of years required.

Sample

Input Data 1

1

Output Data 1

4756.48

Input Data 2

100

Output Data 2

47.56

Data Range

For 100% of the data, 1≤a≤10^5.

Problem Analysis

This is a simple calculation problem, mainly focusing on the data type of the variables. Here, we do not consider the difference between common years and leap years, and we uniformly assume 365 days.

This problem is somewhat humorous; students can try it out and see what the program outputs for a=1! They can compare it with the output sample and the results after submission!!!

#include<bits/stdc++.h>using namespace std;int main(){    long long n;    long double m=150000000000.0,k;    cin>>n;    k=m/(n*3600*24*365);    cout<<fixed<<setprecision(2)<<k<<endl;    return 0;}

Round 1 of the 5th C++ Special Selection Competition for Primary and Secondary Schools in Putian: T1 - Distance to the Sun

Leave a Comment