1 solutions

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

    C :

    #include<stdio.h>
    main() {
    	int m,n,x,a,c,d,e;
    	char b;
    	scanf("%d\n",&m);
    	scanf("%d%c%d\n",&a,&b,&c);
    	scanf("%d%c%d",&d,&b,&e);
    	if(b==':') {
    		if(a==d) {
    			n=e-c;
    			if(m%n==0) {
    				x=m/n;
    			} else x=m/n+1;
    			printf("%d\n",x);
    		}
    		if(a<d) {
    			n=60-c+e;
    			if(m%n==0) {
    				x=m/n;
    			} else x=m/n+1;
    			printf("%d\n",x);
    		}
    	}
    
    }
    

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int sumx(char a[]){
    	/*17:00
    	  17:32*/
    	int i=(a[0]-48)*10*60+(a[1]-48)*60;
    	int k=(a[3]-48)*10+(a[4]-48);
    	int sum=i+k;
    	return sum;
    	
    }
    int main(){
    	int m;
    	cin>>m;
    	char a[10],b[10];
    	cin>>a;
    	cin>>b;
    	int y=sumx(b)-sumx(a);
    	if(m%y==0){
    		cout<<m/y;
    	}else{
    		cout<<m/y+1;
    	}
    	return 0;
    }
    

    Python :

    n=int(input())
    str1=input()
    str2=input()
    def getTime(str_time):    #利用函数转换每行时间单位为分
       l = str_time.split(":")
       t=0
       t+=int(l[0])*60
       t+=int(l[1])
       return t
    a=getTime(str2)-getTime(str1) #相减得到每天看的时间
    day=n//a                      #总时间整除每天看的时间得到看的天数 除的尽正好得到天数 除不尽需再加一天
    if n%a==0:
        print(day)
    else:
        print(day+1)
    
    • 1

    Information

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