Bryce1010模板

http://acm.hdu.edu.cn/showproblem.php?pid=6308

将时间化简为分钟计算,同时不要用浮点数计算,精度会出现问题;

如果采用精度,最好加个0.1

my code

#include<bits/stdc++.h>
using namespace std;
#define ll long long int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a,b;
char ch[100];
scanf("%d%d",&a,&b);
scanf("%s",ch);
int len=strlen(ch);
double time;
if(len==5)
{
double h=(double)(ch[4]-'0');
if(ch[3]=='+')
{
time=h-8.0;
}
else if(ch[3]=='-')
{
time=-8.0-h;
} }
else if(len==6)
{
double h=(double)((double)(ch[4]-'0')*10.0+(double)(ch[5]-'0'));
if(ch[3]=='+')
{
time=h-8.0;
}
else if(ch[3]=='-')
{
time=-8.0-h;
} }
else if(len==7)
{
double h=(double)((double)(ch[4]-'0')+(double)(ch[5]-'0')/10.0);
if(ch[3]=='+')
{
time=h-8.0;
}
else if(ch[3]=='-')
{
time=-8.0-h;
}
}
else if(len==8)
{
double h=(double)((double)(ch[4]-'0')*10.0+(double)(ch[5]-'0')+(double)(ch[7]-'0')/10.0);
if(ch[3]=='+')
{
time=h-8.0;
}
else if(ch[3]=='-')
{
time=-8.0-h;
}
}
time=time*60;
double alltime=a*60+b;
double finaltime=alltime+time;
int hour=(((int)finaltime+24*60)/60)%24;
int minut=((int)finaltime+1440)%60;
if(hour/10)
{
if(minut/10)
{
printf("%d:%d\n",hour,minut);
}
else
{
printf("%d:0%d\n",hour,minut);
}
}
else
{
if(minut/10)
{
printf("0%d:%d\n",hour,minut);
}
else
{
printf("0%d:0%d\n",hour,minut);
}
} } return 0;
} /*
400
11 11 UTC-8
11 12 UTC-9
11 23 UTC-0
11 40 UTC-11
11 11 UTC+8.5
11 40 UTC+11.5
11 11 UTC-8.5
11 40 UTC-11.5
11 11 UTC+8
11 12 UTC+9
11 23 UTC+0
11 40 UTC+11
*/

dls code

// K
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head double d;
int _,h,m,c,sign;
char s[20];
int main() {
for (scanf("%d",&_);_;_--) {
scanf("%d%d%s",&h,&m,s);
h=h*60+m;
sign=s[3]=='+'?1:-1;
sscanf(s+4,"%lf",&d);
c=(int)(d*10+0.1);
c=sign*c*6-8*60;
h+=c;
h%=(24*60);
if (h<0) h+=24*60;
printf("%02d:%02d\n",h/60,h%60);
}
}

太强了,也就15行!!!

HDU6308(2018多校第一场)的更多相关文章

  1. Time Zone 【模拟时区转换】(HDU暑假2018多校第一场)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6308 Time Zone Time Limit: 2000/1000 MS (Java/Others)  ...

  2. 【2018多校第一场】hdu6308-Time Zone(日期)

    Problem Description Chiaki often participates in international competitive programming contests. The ...

  3. HDU6300(2018多校第一场)

    Bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6300 排个序就好了 #include<iostream> #include& ...

  4. HDU6301(2018多校第一场)

    Bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6301 队友AC的,没怎么看 #include<iostream> #incl ...

  5. HDU6299(2018多校第一场)

    Bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6299 两个字符串的排序可以分成四种情况: (1)str1左少右多 vs str2 左多右 ...

  6. HDU6298(2018多校第一场)

    Bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6298 打表找规律: #include<bits/stdc++.h> usin ...

  7. 2019牛客多校第一场 I Points Division(动态规划+线段树)

    2019牛客多校第一场 I Points Division(动态规划+线段树) 传送门:https://ac.nowcoder.com/acm/contest/881/I 题意: 给你n个点,每个点有 ...

  8. 牛客多校第一场 B Inergratiion

    牛客多校第一场 B Inergratiion 传送门:https://ac.nowcoder.com/acm/contest/881/B 题意: 给你一个 [求值为多少 题解: 根据线代的知识 我们可 ...

  9. HDU6581 Vacation (HDU2019多校第一场1004)

    HDU6581 Vacation (HDU2019多校第一场1004) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6581 题意: 给你n+1辆汽车, ...

随机推荐

  1. POJ 2823 Sliding Window (滑动窗口的最值问题 )

    Sliding Window Time Limit: 12000MS   Memory Limit: 65536K Total Submissions: 41264   Accepted: 12229 ...

  2. ArcGIS发布动态空间,并验证

    发布 发布方法见视频. 验证 发布动态空间后,页面底部有 点进去后,使用如下语法验证. {"id": 0,"source": {"type" ...

  3. html5--4-4 audio元素/格式的转换

    html5--4-4 audio元素/格式的转换 学习要点 掌握audio元素的用法 视频/音频文件的格式转换 当前,audio 元素支持三种音频格式: Ogg 免费, 支持的浏览器:Firefox. ...

  4. [原创]java操作word(一)

    一. 需求背景 在做项目的过程中,经常会遇到要把数据库数据导出到Word文件中的需求,因为很多情况下,我们需要将数据导出到WORD中进行打印.此需求可以通过用程序填充数据到word模板中来实现.所谓模 ...

  5. Normalize.css 与传统的 CSS Reset 有哪些区别?

    CSS Reset 是革命党,CSS Reset 里最激进那一派提倡不管你小子有用没用,通通给我脱了那身衣服,凭什么你 body 出生就穿一圈 margin,凭什么你姓 h 的比别人吃得胖,凭什么你 ...

  6. datagrid 行号问题综合

    1.datagrid 左侧行号设置宽度 : 到 easyui.css 中修改 .datagrid-cell-rownumber 中 width 的宽度.

  7. 字面量(literal)与 C 语言复合字面量(compound literals)

    在计算机科学中,字面量(literal)是用于表达源代码中一个固定值的表示法(notation)(字面量是相对变量常量等定义的,无论是常量还是变量,其值在某一时刻总是确定的,只是变量可以反复赋值.刷新 ...

  8. 安装asterisk以及asterisk-gui

           asterisk的安装在ubuntu上自我感觉还是很方便的,虽然也会遇到一些小的问题.下面是本人遇到的   一些问题和解决方法.     1>在ubuntu10.04上安装aste ...

  9. 【EOJ Monthly 2018.2 (Good bye 2017)】

    23333333333333333 由于情人节要回家,所以就先只放代码了. 此题是与我胖虎过不去. [E. 出老千的 xjj] #include<cstdio> #include<c ...

  10. DTP模型之二:(XA协议之二)JTA集成JOTM或Atomikos配置分布式事务(Tomcat应用服务器)

    jotm只能用的xapool数据源,而且很少更新. 一.以下介绍Spring中直接集成JOTM提供JTA事务管理.将JOTM集成到Tomcat中. (经过测试JOTM在批量持久化时有BUG需要修改源码 ...