• ZCMU--2195: Cableway(C语言)


    Description

    A group of university students wants to get to the top of a mountain to have a picnic there. For that they decided to use a cableway.

    A cableway is represented by some cablecars, hanged onto some cable stations by a cable. A cable is scrolled cyclically between the first and the last cable stations (the first of them is located at the bottom of the mountain and the last one is located at the top). As the cable moves, the cablecar attached to it move as well.

    The number of cablecars is divisible by three and they are painted three colors: red, green and blue, in such manner that after each red cablecar goes a green one, after each green cablecar goes a blue one and after each blue cablecar goes a red one. Each cablecar can transport no more than two people, the cablecars arrive with the periodicity of one minute (i. e. every minute) and it takes exactly 30 minutes for a cablecar to get to the top.

    All students are divided into three groups: r of them like to ascend only in the red cablecars, g of them prefer only the green ones and b of them prefer only the blue ones. A student never gets on a cablecar painted a color that he doesn't like,

    The first cablecar to arrive (at the moment of time 0) is painted red. Determine the least time it will take all students to ascend to the mountain top.

    Input

    The first line contains three integers rg and b (0≤r,g,b≤100). It is guaranteed that r+g+b>0, it means that the group consists of at least one student.

    Output

    Print a single number − the minimal time the students need for the whole group to ascend to the top of the mountain.

    Examples

    Input

    1 3 2
    

    Output

    34

    Input

    3 2 1
    

    Output

    33

    题意:给出红绿蓝每组人数,然后缆车从t=0开始按照红绿蓝每一秒来一种,循环颜色,一次最多两个人,缆车到终点需要30s,问全部人上去需要多少时间。

    解析:我们可以利用while(1)然后模拟每一次,对应组人数-2,直到三组人都小于0,表示全部人都上车了,最后加上29s即可(因为 t 从0开始)。

    1. #include
    2. int main()
    3. {
    4. int r,g,b,t=0;
    5. scanf("%d%d%d",&r,&g,&b);
    6. while(1){
    7. if(r>0||g>0||b>0) r-=2,t++;//红色缆车
    8. else break;//如果已经全部上车,立刻退出
    9. if(r>0||g>0||b>0) g-=2,t++;//绿色缆车
    10. else break;
    11. if(r>0||g>0||b>0) b-=2,t++;//蓝色缆车
    12. else break;
    13. }
    14. printf("%d\n",t+29);//上山需要30s,但t从0开始,+29
    15. return 0;
    16. }

  • 相关阅读:
    C陷阱与缺陷 第6章 预处理器 6.2 宏并不是函数
    Java使用joml计算机图形学库,将3D坐标旋转正交投影转为2D坐标
    解析短视频美颜SDK:技术原理与应用
    【二】2D测量 Metrology——add_metrology_object_circle_measure()算子
    [微前端实战]---035react16-资讯,视频,视频详情
    搜维尔科技:【第三期】第九届元宇宙数字人大赛,参赛小组报名确认公告
    面试:正确率能很好的评估分类算法吗
    java高级用法之:在JNA中使用类型映射
    【金融项目】尚融宝项目(十四)
    黑马Java笔记第5讲—方法
  • 原文地址:https://blog.csdn.net/qq_63739337/article/details/126553815