当前位置:网站首页>Luogu p5707 [deep foundation 2. example 12] late for school

Luogu p5707 [deep foundation 2. example 12] late for school

2022-06-25 14:50:00 䨁 逦

Title Description

yyy Our school requires that in the morning 8 We'll be there by two o'clock . School to yyy There are... In my family s(s\le 10000)s(s≤10000) rice , and yyy We can use v(v<10000)v(v<10000) Walk to school at a constant speed of meters per minute . Besides, it has to spend extra money on the way to school 10 Minutes for garbage sorting . Excuse me, in order to avoid being late yyy When is the latest time to go out ? Output HH:MM Time format of , Fill in zero if there are less than two digits . Because it's a long way , yyy You may have to start a day earlier , But it can't be more than a day in advance .

Input format

Two positive integers s,v, The meaning has been given in the title .

Output format

hh:mm The latest time to leave home ( when : branch , Two digits must be output , Fill in the front of less than two 0)

I/o sample

Input #1 Copy

100 99

Output #1 Copy

07:48

C Language version ,

There are several test points that can not pass when writing the questions , Then I looked carefully and found that C The problem and complement of wide language domain 0 The problem of

use printf() Function must be complemented by lines 0 The operation can be written as follows printf("%02d",n); The non-zero digit part can be changed .

Here is AC Code

#include<stdio.h>
#include<math.h>
int main()
{
    int n=0,v=0,t=0,s=0;
    scanf("%d %d",&s,&v);
    if(s%v==0) { t=s/v+10;}
    else t=s/v+11;
    if(t<=8*60)
    {
        int h=0,m=0;
        t=8*60-t;
        h=t/60;
        m=t%60;
        printf("%02d:%02d",h,m);
    }
    else 
    {
        int h=0,m=0;
        t=32*60-t;
        h=t/60;
        m=t%60;
        printf("%02d:%02d",h,m);
    }
    return 0;
}

原网站

版权声明
本文为[䨁 逦]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202200518466557.html