1 条题解

  • 0
    @ 2023-6-11 12:17:11

    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

    信息

    ID
    2380
    时间
    1000ms
    内存
    32MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者