Time Zone

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4337    Accepted Submission(s): 1278

Problem Description
Chiaki often participates in international competitive programming contests. The time zone becomes a big problem.
Given a time in Beijing time (UTC +8), Chiaki would like to know the time in another time zone s.
 
Input
There are multiple test cases. The first line of input contains an integer T (1≤T≤106), indicating the number of test cases. For each test case:
The first line contains two integers a, b (0≤a≤23,0≤b≤59) and a string s in the format of "UTC+X'', "UTC-X'', "UTC+X.Y'', or "UTC-X.Y'' (0≤X,X.Y≤14,0≤Y≤9).
 
Output
For each test, output the time in the format of hh:mm (24-hour clock).
 
Sample Input
3
11 11 UTC+8
11 12 UTC+9
11 23 UTC+0
 
Sample Output
11:11
12:12
03:23
 
 
题目大意:
给你UTC+8的时间,求给定时区的时间。
 
模拟题。
是水题没错的,但是不仔细做还是会wa得很惨QAQ...
1、这里的时区并不是标准的时区定义,所以直接根据差值加减就好啦。
2、转化成分钟加加减减或许是最好的方法。
3、X可能是两位数。
我是先把给的时间转移到UTC+0(UTC-0),这样处理起来感觉更方便。
 
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<cmath> using namespace std; int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a,b;
char s[];
scanf("%d%d%s",&a,&b,s);
int minute=a*+b-*; int add=,pos;
for(pos=;s[pos]!='\0';pos++)
{
if(s[pos]=='.')break;
add=add*+s[pos]-'';
}
if(s[pos]=='.')add=add*+(s[pos+]-'')*;
else add=add*; if(s[]=='+')
minute+=add;
else
minute-=add;
if(minute>=*)
minute=minute-*;
if(minute<)
minute=minute+*; printf("%02d:%02d\n",minute/,minute%);
}
return ;
}

hdu 6308 Time Zone (模拟+字符串处理)的更多相关文章

  1. 二叉搜索树的结构(30 分) PTA 模拟+字符串处理 二叉搜索树的节点插入和非递归遍历

    二叉搜索树的结构(30 分) PTA 模拟+字符串处理 二叉搜索树的节点插入和非递归遍历   二叉搜索树的结构(30 分) 二叉搜索树或者是一棵空树,或者是具有下列性质的二叉树: 若它的左子树不空,则 ...

  2. 模拟/字符串处理 UVALive 6833 Miscalculatio

    题目传送门 /* 模拟/字符串处理:主要是对*的处理,先把乘的预处理后再用加法,比如说是:1+2*3+4 = 1+..6+4 = 11 */ #include <cstdio> #incl ...

  3. hdu 2629 Identity Card (字符串解析模拟题)

    这题是一个字符串模拟水题,给12级学弟学妹们找找自信的,嘿嘿; 题目意思就是要你讲身份证的上的省份和生日解析出来输出就可以了: http://acm.hdu.edu.cn/showproblem.ph ...

  4. HDU 5510---Bazinga(指针模拟)

    题目链接 http://acm.hdu.edu.cn/search.php?action=listproblem Problem Description Ladies and gentlemen, p ...

  5. HDU 5965 扫雷 【模拟】 (2016年中国大学生程序设计竞赛(合肥))

    扫雷 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submissi ...

  6. HDU 4668 Finding string (解析字符串 + KMP)

    转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove 题意:给出一个压缩后的串,以及一个模式串,问模式串 ...

  7. HDU 5047 Sawtooth(大数模拟)上海赛区网赛1006

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5047 解题报告:问一个“M”型可以把一个矩形的平面最多分割成多少块. 输入是有n个“M",现 ...

  8. POJ 1016 模拟字符串

    Numbers That Count Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 20396   Accepted: 68 ...

  9. HDU 4041 Eliminate Witches! --模拟

    题意: 给一个字符串,表示一颗树,要求你把它整理出来,节点从1开始编号,还要输出树边. 解法: 模拟即可.因为由括号,所以可以递归地求,用map存对应关系,np存ind->name的映射,每进入 ...

随机推荐

  1. FPGA基础(verilog语言)——语法篇

    verilog语言简介 verilog语言是一种语法类似于c的语言,但是与c语言也有不同之处,比如: 1.verilog语言是并行的,每个always块都是同时执行,而c语言是顺序执行的 2.veri ...

  2. Linux下安装和使用WPS,体验良好

    最近,我在ubuntu18.04.3下面使用LibreOffice,感觉良好. 正值政府机关在进行2019年度正版软件使用情况整改,保护知识产权,我表示热烈欢迎并强烈支持. 通过摸底,因为以前采购的w ...

  3. 【论文阅读】Between-class Learning for Image Classification

    文章:Between-class Learning for Image Classification 链接:https://arxiv.org/pdf/1711.10284.pdf CVPR2018 ...

  4. pyinstaller打包python文件成exe(原理.安装.问题)

    py文件打包成exe文件的方式一共有三种:py2exe.PyInstaller和cx_Freeze 本文分四个步骤来详讲如何用PyInstaller将py文件打包成exe文件 1. PyInstall ...

  5. django-migrate一败再败

    python3 manage.py makemigrations # 生成数据库迁移文件 python3 manage.py migrate # 迁移数据库 简简单单两条命令就完成了django的数据 ...

  6. 1、Docker 简介

    目录 Docker 起源 Docker 架构 特性 局限 名称空间隔离 原理 Control Groups (cgroups) Docker Docker 啥是docker? Docker 是一个开源 ...

  7. 白话OAuth2用户认证及鉴权标准流程

    一.OAuth2需求场景 在说明OAuth2需求及使用场景之前,需要先介绍一下OAuth2授权流程中的各种角色: 资源拥有者(User) - 指应用的用户 认证服务器 (Authorization S ...

  8. 还在用背单词App?使用Python开发英语单词自测工具,助你逆袭单词王!

    学英语广告 最近也许是刚开学的原因,不管是公众号,还是刷抖音,导出都能看到关于学英语.背单词的广告. 不知道现在学生们背单词买的什么辅导材料.反正我们上学那会,<星火阅读>特别的火.记得当 ...

  9. KETTLE多表关联的同步一张表的两种实现方式

    以下操作都在5.0.1版本下进行开发,其余版本可以进行自动比对 在平时工作当中,会遇到这种情况,而且很常见.比如:读取对方的多个视图或者表,写入目标库的一张表中,就涉及到多表的同步. 多表同步可以有以 ...

  10. luogu P3807 【模板】卢卡斯定理

    求 C(n,n+m)%p C(m,n)%p=C(m%p,n%p)*C(m/p,n/p) #include<cstdio> #include<cstring> #include& ...