1 solutions

  • 0
    @ 2025-3-3 16:33:59

    C :

    #include<stdio.h>
    int main(){
    	double h=100.0;
    	int n=0;
    	while(h>=0.5){
    		 h=h/2.0;
    		 n++;
    	}
    	printf("%d",n);
    	return 0;
    }
    

    C++ :

    #include <iostream>
    #include <iomanip>
    #include <cmath>
    
    using namespace std;
    
    int main(){
    	double s=100,c=0;
    	for(int i=1;i<=1000000;i++){
    		if(s>=0.5){
    			s/=2;
    			c++;
    		}else{
    			cout<<c;
    			break;
    		}
    	}
    }
    

    Python :

    n=100
    s=0
    while n>=0.5:
        n=n/2
        s+=1
    print(s)
      
    
    • 1

    Information

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