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. JavaScript学习第四天

    1.自定义属性,使用好索引值 例子: 下面有一段js代码: <script> window.onload = function(){ var oBtn = document.getElem ...

  2. 数据结构之 字符串---字符串匹配(kmp算法)

    串结构练习——字符串匹配 Time Limit: 1000MS Memory limit: 65536K 题目描述   给定两个字符串string1和string2,判断string2是否为strin ...

  3. maven项目所遇到的问题解决

    1.在Eclipse中创建Maven的Web项目时出现错误:An internal error occurred during: "Retrieving archetypes:". ...

  4. linux下mycat读写分离的配置

    为什么要配置读写分离,我想我就不需要再赘述了,那么在mycat下如何进行读写分离的配置,配置之后的实际效率又如何呢?我上午根据文档捣鼓和测试了一下,这里做一下记录: 最开始,我们还是要配置mysql本 ...

  5. yolo-开源数据集coco kitti voc

    1.kitti数据集(参考博客:https://blog.csdn.net/jesse_mx/article/details/65634482  https://blog.csdn.net/baoli ...

  6. UNP总结 Chapter 11 名字与地址转换

    本章讲述在名字和数值地址间进行转换的函数:gethostbyname和gethostbyaddr在主机名字与IP地址间进行转换,getservbyname和getservbyport在服务器名字和端口 ...

  7. 将List<T>集合用DataGridView展示

    一.若要将List<T>集合的值赋值给DataGridView,首先要DataGridView中的列的DataPropertyName的值要和此集合的T类型的属性字段的名称,类型一致,并且 ...

  8. centos7 安装 python3.5

    centos7 安装 python3.5 一. python虚拟环境virtualenv VirtualEnv用于在一台机器上创建多个独立的python运行环境,VirtualEnvWrapper为前 ...

  9. Linux Ctrl+Z的使用方法

    假设你发现前台运行的一个程序需要很长的时间,但是需要干其他的事情,你就可以用 Ctrl-Z ,终止这个程序,然后可以看到系统提示: [1]+ Stopped /root/bin/rsync.sh 然后 ...

  10. linux tar命令及解压总结

    把常用的tar解压命令总结下,当作备忘: tar -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其 ...