swustoj Aconly时间戳(0275)
来源:互联网 发布:淘宝怎么提高销量2016 编辑:程序博客网 时间:2024/06/05 12:02
时间戳是自 1970年1月1日(00:00:00 GMT)以来的秒数。然而Aconly不喜欢这个东西,所以他制定了一种新的时间戳叫Aconly时间戳,它是自2009年1月1日(00:00:00 北京时间)以来的秒数。例如0 就是2009-01-01 00:00:00 , 60就是2009-01-01 00:01:00。
Description
有多组测试数据。每组数据一个整数n(0<= n <=31535999),即Aconly时间戳。
Input
输出相应的北京时间。每组数据占一行。
Output
1
2
3
4
5
0
60
10000000
31535999
Sample Input
1
2
3
4
5
2009-01-01 00:00:00
2009-01-01 00:01:00
2009-04-26 17:46:40
2009-12-31 23:59:59
/*由于题目数据只有一年,So没有判断闰年。 题目太水:( ̄▽ ̄)*/#include<iostream>#include<stdio.h>#include<algorithm>using namespace std;int main(){int n;int a[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };while (cin >> n){int y=1,t=0, s=0, f=0, m=0;//月 天 时 分 秒t = n / (60 * 60 * 24);n = n % (60 * 60 * 24);s = n / (60 * 60);n %= (60 * 60);f = n / 60;n %= 60;m = n;int sum = 0;int index = -1;for (int i = 0; i < 12; i++){sum += a[i];if (sum >= t){index = i;break;}}y = index + 1;sum -= a[index];t = t - sum + 1;cout << "2009-";//注意格式 数据只有一位时,要补0if (y <= 9){cout << "0";}cout << y << '-';if (t <= 9){cout << '0';}cout << t << ' ';if (s <= 9){cout << '0';}cout << s << ":";if (f <= 9){cout << '0';}cout << f << ":";if (m <= 9){cout << '0';}cout << m << endl;//2009 - 01 - 01 00 : 01 : 00}return 0;}
0 0
- swustoj Aconly时间戳(0275)
- OJ.Aconly时间戳
- swustoj---1091
- swustoj(667)
- swustoj---254翻煎饼
- swustoj----142猴子报数
- swustoj---700Delete Numbers
- 翻煎饼 swustoj 254
- swustOJ 1378 Best Grass
- swustOJ 1107 单向公路
- swustOJ 1615寻宝
- swustoj 143 汉诺塔问题
- swustoj---251邮票
- swustoj Locker doors(0480)
- swustoj沙漠储油点
- swustoj(翻煎饼)
- swustoj(0541)
- swustoj似曾相识(0314)
- org.hibernate.NonUniqueObjectException
- 基于Opencv平台开发的程序在其它电脑上独立运行
- CSU 1898: 复盘拉火车
- 【LeetCode】Convert Sorted Array to Binary Search Tree 解题报告
- label大小变换后,位置依然窗体居中
- swustoj Aconly时间戳(0275)
- 开源265 IP
- 分治尝试A
- Android源码bootable解析之bootloader LK(little kernel)
- Md5Util
- ES6知识库汇总一
- 给EditText左右两边设置图片与监听(drawableLeft/drawableRight)/弹出键盘
- MIT 线性代数(28—30)读书笔记
- opencv2、3舍弃了CvImage类,写好不容易找到