1 solutions

  • 0
    @ 2025-3-3 16:32:52

    C++ :

    #include <iostream>
    using namespace std;
    
    int main(){
    	int c = 1;	
    	double t = 2,s = 2,x;
    	cin>>x;
    	while(s < x){
    		t = t * 0.98;
    		s = s + t;
    		c++;
    	}
    	
    	cout<<c<<endl;
    }
    

    Python :

    n = float(input())
    i = 0
    a = 2
    b = 0
    while(b < n):
        b += a
        a *= 0.98
        i += 1
    print(i)
    
    • 1

    Information

    ID
    10456
    Time
    1000ms
    Memory
    32MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By