zoukankan      html  css  js  c++  java
  • 【2018.10.20】noip模拟赛Day3 飞行时间

    今天模拟赛题目

    纯考输入的傻逼题,用$scanf$用到思想僵化的我最终成功被$if$大法爆$0$了(这题只有一组$100$分数据)。

    输入后面那个$(+1/2)$很难$if$判断,所以我们要判两个字符串中间空的是空格还是换行。$getchar$和$cin.getline$都可以做到。

    会输入基本上就做完了。至于题面的意思,也比较绕,但想想就明白了,飞机来回两次飞行一次是顺着地球自转、一次是逆着地球自转,所以时间可能一长一短。

    根据“假设飞机来回飞行时间相同,求飞机的飞行时间”一句话,结合样例,可知答案就是来回两次飞行的平均耗时。

    另外,输多字符串是没事情的……我之前为这破事想了老久……

    最后祝贺这种傻逼题爆$0$吧。

     1 #include<bits/stdc++.h>
     2 #define inf 2139062143
     3 #define ll long long
     4 #define MAXN 100100
     5 using namespace std;
     6 inline int read()
     7 {
     8     int x=0,f=1;char ch=getchar();
     9     while(!isdigit(ch)) {if(ch=='-')f=-1;ch=getchar();}
    10     while(isdigit(ch)) {x=x*10+ch-'0';ch=getchar();}
    11     return x*f;
    12 }
    13 char ch[50];
    14 int n;
    15 struct Time
    16 {
    17     int h,m,s;
    18     Time(){h=m=s=0;}
    19     void init()
    20     {
    21         n=strlen(ch+1);
    22         h=(ch[1]-'0')*10+ch[2]-'0',m=(ch[4]-'0')*10+ch[5]-'0',s=(ch[7]-'0')*10+ch[8]-'0';
    23         scanf("%s",ch+1);if(ch[1]=='(') {h+=24*(ch[3]-'0');scanf("%s",ch+1);}
    24     }
    25     void print()
    26     {
    27         printf("%02d:%02d:%02d
    ",h,m,s);
    28     }
    29     void div2()
    30     {
    31         if(h&1) m+=60;h>>=1;
    32         if(m&1) s+=60;m>>=1;s>>=1;
    33     }
    34 }a,b,c,d,e,f;
    35 Time operator + (const Time x,const Time y)
    36 {
    37     Time res;
    38     res.s=x.s+y.s,res.m=res.s/60,res.s%=60;
    39     res.m+=x.m+y.m,res.h=res.m/60,res.m%=60;
    40     res.h+=x.h+y.h;
    41     return res;
    42 }
    43 Time operator - (const Time x,const Time y)
    44 {
    45     Time res;
    46     res.s=x.s-y.s;if(res.s<0) res.s+=60,res.m=-1;
    47     res.m+=x.m-y.m;if(res.m<0) res.m+=60,res.h=-1;
    48     res.h+=x.h-y.h;
    49     return res;
    50 }
    51 int main()
    52 {
    53     freopen("timezone.in","r",stdin);
    54     freopen("timezone.out","w",stdout);
    55     int T=read();scanf("%s",ch+1);
    56     while(T--)
    57     {
    58         a.init();b.init();c.init();d.init();
    59         //a.print();b.print();c.print();d.print();
    60         a=b-a;c=d-c;
    61         //c.print();b.print();e.print();
    62         d=c+a;d.div2();d.print();//puts("");
    63     }
    64 }
    View Code
  • 相关阅读:
    NORDIC BLE MAC ADDR
    dbm和发射功率得对照表
    git切换账号邮箱
    文件编码问题造成的汉字输出乱码问题
    自定义printf 打印函数
    NORDIC 烧录BLE协议栈后不能用JLINK仿真bootloader问题及修改方案
    NORDIC BLE升级
    NORDIC ble RSSI
    NORDIC 错误文件
    NORDIC 协议栈下使用硬件定时器
  • 原文地址:https://www.cnblogs.com/scx2015noip-as-php/p/9821668.html
Copyright © 2011-2022 走看看