1 solutions

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

    C :

    #include<stdio.h>
    void main()
    {
    	int m,n,h,i=1;
    	scanf("%d%d%d",&m,&n,&h);
    	while(h>0){
    		h-=m;
    		if(h>0){
    			i++;
    			h+=n;
    		}else{
    			break;	
    		}	
    	}					
    	printf("%d",i);							 
    } 
    

    C++ :

    #include<iostream>
    using namespace std;
    
    int main(){
    	int m,n,h,i,j;
    	cin>>m>>n>>h;
    	i=0;
    	j=0; 
    	while(true){
    		i=i+m;
    		j++;
    		
    		if(i>=h){
    			break;
    		}
    		
    		i=i-n;
    	}
    	
    	cout<<j<<endl;	
    }
    
    

    Python :

    m, n, h = map(int,input().split());
    d = 1
    s = 0
    while s <= h:
        s = d*(m-n) 
        if s < (h-m):
            d += 1
        elif s >= (h-m):
            print(d+1) 
            break;
     
    
    • 1

    Information

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