【topcoder第一弹】 SRM 144 Div.2 whatTime
来源:互联网 发布:淘宝葡萄酒 编辑:程序博客网 时间:2024/06/06 00:52
Problem Statement
Computers tend to store dates and times as single numbers which represent the number of seconds or milliseconds since a particular date. Your task in this problem is to write a method whatTime, which takes an int,seconds, representing the number of seconds since midnight on some day, and returns a String formatted as "<H>:<M>:<S>". Here, <H> represents the number of complete hours since midnight, <M> represents the number of complete minutes since the last complete hour ended, and <S> represents the number of seconds since the last complete minute ended. Each of <H>, <M>, and <S> should be an integer, with no extra leading 0's. Thus, ifseconds is 0, you should return "0:0:0", while if seconds is 3661, you should return "1:1:1".Definition
Class:TimeMethod:whatTimeParameters:intReturns:StringMethod signature:String whatTime(int seconds)(be sure your method is public)Limits
Time limit (s):2.000Memory limit (MB):64Constraints
-seconds will be between 0 and 24*60*60 - 1 = 86399, inclusive.Examples
0)0
Returns: "0:0:0"1)
3661
Returns: "1:1:1"2)
5436
Returns: "1:30:36"3)
86399
Returns: "23:59:59"
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.
做topcoder还要现下客户端,外国服务器连的慢,就直接把页面内容粘过来了……
题目大意:给出秒数,转换成“时:分:秒”格式。
题目分析:水无坑,算法简单易懂。
code:
public class Time{public String whatTime(int seconds){int h,m;String ans;h=seconds/3600;seconds%=3600;m=seconds/60;seconds%=60;ans=""+h+":"+m+":"+seconds;return ans;}}
PS:准备期末考试,停了一段时间。从队长处得到topcoder的access,上来先水一发。
PSS:个人感觉topcoder写法较诡异……
0 0
- 【topcoder第一弹】 SRM 144 Div.2 whatTime
- TopCoder SRM 144 DIV 2
- 【topcoder】 SRM 144 div 2 200
- TopCoder SRM 144 DIV 1
- Topcoder SRM 462 DIV 2
- topcoder srm 518 div 2
- TopCoder SRM 561 Div 2
- Topcoder SRM 565 Div.2
- Topcoder SRM 628 DIV 2
- topcoder whatTime
- TopCoder算法竞赛题1:SRM 144 DIV 2, 250-point
- topcoder SRM 144 DIV 1 by First_Blood
- TopCoder——SRM 516 DIV 2
- TopCoder——SRM 518 DIV 2
- TopCoder——SRM 519 DIV 2
- Topcoder SRM 505 Div 2 hard
- TopCoder——SRM 520 DIV 2
- TopCoder——SRM 521 DIV 2
- Java工具类总结二
- 验证数字为空
- HDU 1385 Minimum Transport Cost(Floyd+打印字典序最小路径)
- Java工作中常用工具类总结一
- 关于在VS2008和VS2010中禁用及卸载Visual Assist X的方法研究
- 【topcoder第一弹】 SRM 144 Div.2 whatTime
- 画了个Android——Canvas类的使用
- 淘宝商城model部分
- bbed初体验
- android 水平button等宽
- git 的本地基本操作
- C#中将结构类型数据存储到二进制文件中方法
- Java常用工具类三 -- 正则表达式
- alsa 音频库的移植