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. vuejs实现折叠面板展开收缩动画

    vuejs通过css3实现元素固定高度到auto高度的动画和auto高度到固定高度的动画. 循环列表,html: <template> <div class="newsli ...

  2. 人生苦短之Python迭代器

     迭代 在Python中,如果给定一个list或者touple,我们可以通过for循环来遍历,将值依次取出,这种遍历称为迭代. 在Python中是通过for...in..来进行遍历的,在Java中则是 ...

  3. pypi指定下载源

    pip install -i http://pypi.douban.com/simple/ scipy==0.19.0

  4. IOS开发学习笔记(2)-----UIButton 详解

    1. [代码][C/C++]代码     //这里创建一个圆角矩形的按钮    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRou ...

  5. ubuntu下安装cpython 0.2x

    Quick installation of cython: Step 1: Update system: sudo apt-get update Step 2: Install: cython Ate ...

  6. eclipse 切换数据库

    PS:jdbc.url = 后面的路径就是连接的数据库,如果需要连接开发库(dev_cfin),则只需要将tg_cfin 换成 dev_cfin,重启后台即可.

  7. bzoj1012最大数maxnumber——单调栈

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1012 单调栈水题:用了一下lower_bound二分. 代码如下: #include< ...

  8. rsync(六)命令中文手册

    rsync(1) rsync(1) 名称 rsync - 一个快速.多功能的远程(和本地)文件拷贝工具 摘要 Local: rsync [OPTION...] SRC... [DEST] Access ...

  9. 二、mysql安装详解

    step1:打开下载的mysql安装文件(mysql-5.5.36-win32.msi),双击运行,如下图: step2:点击“Next”按钮继续,如下图: step3:点击“勾选”,点击“Next” ...

  10. 爬虫库之BeautifulSoup学习(一)

    Beautiful Soup的简介 简单来说,Beautiful Soup是python的一个库,最主要的功能是从网页抓取数据. 官方解释如下: Beautiful Soup提供一些简单的.pytho ...