zoukankan      html  css  js  c++  java
  • hdu4509 湫湫系列故事——减肥记II

      听说腾讯的编程马拉松启动了,然后我一直准备报名,然后不知道为啥等我报名那一天就没有位置了...无奈了,校赛我也是昨天刚报上名。我在想什么呢?!

    在HDU上找题目做来看看。

    这题就是模拟了。注意时间循环的时候是for(i=beign;i<end;++i)这块一定是i<end,不然会出错的。

     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <string.h>
     4 #define maxn 24*60+100
     5 using namespace std;
     6 bool daytime[maxn];
     7 int main()
     8 {
     9     int begin,end;
    10     int bhour,bmin,ehour,emin;
    11     int n,res,cnt;
    12     int i,j;
    13     while(~scanf("%d",&n))
    14     {
    15         memset(daytime,0,sizeof(daytime));
    16         cnt=0;
    17         while(n--)
    18         {
    19             scanf("%d:%d",&bhour,&bmin);
    20             scanf("%d:%d",&ehour,&emin);
    21             begin=bhour*60+bmin;
    22             end     =ehour*60+emin;
    23             if(begin>end||begin<0||begin>23*60+59||end<0||end>23*60+59)
    24                 continue;
    25             if(begin==end)
    26                 continue;
    27             for(i=begin;i<end;++i)
    28             {
    29                 if(!daytime[i])
    30                 {
    31                     cnt++;
    32                     daytime[i]=1;
    33                 }
    34             }
    35         }
    36         res=24*60-cnt;
    37 //        printf("cnt=%d\n",cnt);
    38         printf("%d\n",res);
    39     }
    40     return 0;
    41 }
  • 相关阅读:
    Java语法总结 线程
    Java多线程编程总结
    eclipse插件开发
    Java私塾的一些基础练习题(一)
    反射练习
    内部类实现动态链表(增,删,查,打印)
    oracle 存储过程第四天
    java 面向对象个人理解
    jsp的flash小例子
    oralcle 存储过程批处理
  • 原文地址:https://www.cnblogs.com/symons1992/p/2976146.html
Copyright © 2011-2022 走看看