P1423 Xiaoyu swimming, P1423 Xiaoyu swimming

Source: Internet
Author: User

P1423 Xiaoyu swimming, P1423 Xiaoyu swimming
Description

XiaoYu was happy to swim, but she quickly found out that she was not strong enough to swim very tired. It is known that XiaoYu can swim 2 meters in the first step, but as she gets tired and has little strength, she can only swim 98% away from the previous step in every step. Now, XiaoYu wants to know how many steps she needs to travel to a place x meters away. Please program to solve this problem.

Input/Output Format

Input Format:

 

Enter a number (not necessarily an integer, less than 100 m) to indicate the target distance of the game.

 

Output Format:

 

The output is an integer indicating the total number of steps that XiaoYu needs to swim.

 

Input and Output sample input sample #1:
4.3
Output sample #1:
3

 

 

 

#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#define lli long long int using namespace std;void read(int &n){char c='+';int x=0;bool flag=0;while(c<'0'||c>'9'){c=getchar();if(c=='-')flag=1;}while(c>='0'&&c<='9')x=x*10+(c-48),c=getchar();flag==1?n=-x:n=x;}int a[10];double will;double now=0;double base=2;int step;int main(){cin>>will;while(now<will){step++;now+=base;base*=0.98;}printf("%d",step);return 0;}

  

Related Keywords:
Related Article

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.