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. ubuntu 12.04安装alsa-lib、alsa-utils【转】

    1. alsa-lib ./configure sudo make install 注意:默认是安装到/usr/这个目录下面,但是我测试多了多次,安装了alsa-lib之后,系统就没有声音了,也没有找 ...

  2. 【MongoDB学习-在.NET中的简单操作类】

    1.新建MVC项目, 管理NuGet包,进入下载MongDB.net库文件 2.新增项目DAL数据访问层,引用以下库文件: 3.C# 访问MongoDB通用方法类: using MongoDB.Dri ...

  3. plsql导入cvs 时提示missing right parenthesis

    删除自动生成的时间格式值,如:SQL function框里自动生成的值

  4. codeforces 450B B. Jzzhu and Sequences(矩阵快速幂)

    题目链接: B. Jzzhu and Sequences time limit per test 1 second memory limit per test 256 megabytes input ...

  5. [转载] Android raw与assets区别

    *res/raw和assets的相同点: 1.两者目录下的文件在打包后会原封不动的保存在apk包中,不会被编译成二进制. *res/raw和assets的不同点:1.res/raw中的文件会被映射到R ...

  6. multi_socket

    threading_test.py #threading #为什么在命令行可以执行,F5不能执行 #线程处理能导致同步问题 from socketserver import TCPServer,Thr ...

  7. mysql审计实现方法

    Mysql版本: 5.6.24-72.2 一.通过init-connect + binlog 实现MySQL审计功能 基本原理: 由于审计的关键在于DML语句,而所有的DML语句都可以通过binlog ...

  8. C++模板之隐式实例化、显示实例化、隐式调用、显示调用和模板特化详解

    模板的实例化指函数模板(类模板)生成模板函数(模板类)的过程.对于函数模板而言,模板实例化之后,会生成一个真正的函数.而类模板经过实例化之后,只是完成了类的定义,模板类的成员函数需要到调用时才会被初始 ...

  9. HTML5.与JQUERY与AJAX常见面试题

    1. HTML5 1.1.简要描述 HTML5中的本地存储 参考答案: 很多时候我们会存储用户本地信息到电脑上,例如:比方说用户有一个填充了一半的长表格,然后突然网络连接断开了,这样用户希望你能存储这 ...

  10. OpenService 打开一个已经存在的服务

    SC_HANDLE WINAPI OpenService( _In_ SC_HANDLE hSCManager, _In_ LPCTSTR lpServiceName, _In_ DWORD dwDe ...