1 条题解

  • 0
    @ 2025-2-14 21:11:42

    C++ :

    #include<cstdio>
    using namespace std;
    int a,b;
    int main()
    {
    	int m,s,t,i;
    	scanf("%d%d%d",&m,&s,&t);
    	for(i=1;i<=t;++i)
    	{
    		a+=17;
    		if(m>=10)
    		{
    			b+=60;
    			m-=10;
    		}
    		else
    		  m+=4;
    		if(b>a)
    		  a=b;
    		if(a>=s)
    		{
    			printf("Yes");
    			printf("\n");
    			printf("%d",i);
    			return 0;
    		}
    	}
    	if(a>=s)
    	{
    		printf("Yes");
    		printf("\n");
    		printf("%d",i-1);
    	}
    	if(a<s)
    	{
    		printf("No");
    		printf("\n");
    		printf("%d",a);
    	}
    	return 0;
    }
    
    

    Pascal :

    var 
    m,s,t,ti:longint;  
    ms:array[1..2,0..300000] of longint;  
    ts:array[0..300000] of longint;  
    begin 
    readln(m,s,t);  
    ms[2,0]:=m;  
    ts[0]:=0;  
    for ti:=1 to t do 
    begin 
    if ms[2,ti-1]>=10 then
    begin 
    ms[1,ti]:=ms[1,ti-1]+60;  
    ms[2,ti]:=ms[2,ti-1]-10;  
    end 
    else 
    begin 
    ms[1,ti]:=ms[1,ti-1]; 
    ms[2,ti]:=ms[2,ti-1]+4;  
    end;  
    if ts[ti-1]+17>ms[1,ti] then ts[ti]:=ts[ti-1]+17 else ts[ti]:=ms[1,ti]; 
    if ts[ti]>=s then 
    begin 
    writeln('Yes');  
    writeln(ti);  
    close(input);  
    close(output);  
    halt;  
    end;  
    end;  
    writeln('No'); 
    writeln(ts[t]); 
    end.  
    
    • 1

    信息

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