SRM 144DIV2 200 C++
来源:互联网 发布:ue设计软件 编辑:程序博客网 时间:2024/05/16 15:42
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.
#include<iostream>#include<string>#include<sstream>using namespace std;class Time{public: int SECONDS_PER_MINUTE = 60; int SECONDS_PER_HOUR = 3600;string whatTime(int seconds){int hour = seconds/SECONDS_PER_HOUR;int minute = (seconds % SECONDS_PER_HOUR) / SECONDS_PER_MINUTE;int second = seconds % SECONDS_PER_MINUTE;stringstream ss;string str1,str2,str3;ss<<hour;ss>>str1;ss.clear();ss<<minute;ss>>str2;ss.clear();ss<<second;ss>>str3;return str1+":"+ str2 + ":" + str3;}};
0 0
- SRM 144DIV2 200 C++
- TopCoder SRM 144 DIV2(200-point)
- TopCoder SRM 144 div2
- SRM 144 DIV2
- Topcoder SRM 683 Div2 - C
- Topcoder SRM 636 Div2 C
- TopCoder SRM 637 Div2 C
- topcoder 记录 srm 144 div2
- TopCoder SRM 144 DIV2(550-point)
- TopCoder SRM 144 DIV2 550points
- Topcoder SRM 144 Div2 1100 (树形dp)
- TopCoder01 SRM 157 DIV2 200分
- SRM 114 DIV2 [550]
- SRM 398 DIV2 [250]
- SRM 399 DIV2 [250]
- SRM 387 DIV2 [250]
- SRM 387 DIV2 [600]
- SRM 397 DIV2 [500]
- Gson具体用法
- Android webview详解
- unity3d 关于FindObjectsOfType和FindObjectOfType 之遍历对象
- Git分支管理策略
- 计算机类期刊
- SRM 144DIV2 200 C++
- 玩转nodeJS系列:使用cluster创建nodejs单机多核集群(多进程)
- Linux常用命令汇总
- 写入orauts.dll 时出错
- C#中的接口
- 开发笔记
- iOS进度条 自定义圆角 UIProgressView
- cookie 和session 的区别详解
- iOS开发 colorWithAlphaComponent的场景及效果