2 solutions

  • 3
    @ 2023-9-17 21:42:37
    #include <iostream>
    using namespace std;
    double h,road;
    int main(){
    	cin>>h;
    	road=h;
    	int i=1;
    	while(i<10){
    		i++,h/=2;
    		road+=2*h; 
    	}
    	cout<<road<<endl;
    	cout<<h/2<<endl;       
    	return 0;
    }
    
    • 1
      @ 2024-7-11 20:10:53

      通俗易懂!!!

      #include <bits/stdc++.h>
      using namespace std;
      int main()
      {
      	double h,s=0;
      	cin>>h;
      	for(int i=1;i<=10;i++)
      	{
      		s+=h;
      		h/=2;
      		s+=h;
      	}
      	cout<<s-h<<endl<<h;
      	return 0;
      }
      
      • 1

      Information

      ID
      576
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      1
      Tags
      # Submissions
      36
      Accepted
      28
      Uploaded By