topcoder 的一些输入输出格式
自从上年的11月份参加过TC的比赛后,就再也没有参加了,因为它的输入输出格式比较难接受,还有它的页面字体比较小,看得我很辛苦...藉口藉口~~懒而已!不过以后我会尽量去参加的,为了提高自己的编程能力。
以 SRM 144 DIV 2 的 200 分题目为例,记录下两种输入输出格式吧。
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, if seconds is 0, you should return "0:0:0", while if seconds is 3661, you should return "1:1:1". |
|||||||||||||
Definition |
|||||||||||||
|
|||||||||||||
Limits |
|||||||||||||
|
|||||||||||||
Constraints |
|||||||||||||
- |
seconds will be between 0 and 24*60*60 - 1 = 86399, inclusive. |
||||||||||||
Examples |
|||||||||||||
0) |
|||||||||||||
|
|||||||||||||
1) |
|||||||||||||
|
|||||||||||||
2) |
|||||||||||||
|
|||||||||||||
3) |
|||||||||||||
|
JAVA 版
public class Time{
public String whatTime(int seconds){
int h = seconds / 3600;
int m = (seconds % 3600) / 60;
int s = seconds % 3600 - m * 60;
return h + ":" + m + ":" + s;
}
}
C++ 版
#include <iostream>
using namespace std;
class Time{
public:
string whatTime(int seconds)
{
int h = seconds / 3600;
int m = (seconds % 3600) / 60;
int s = seconds % 3600 - m * 60;
char buf[40];
sprintf(buf, "%d:%d:%d", h, m, s);
return string(buf);
}
};
topcoder 的一些输入输出格式的更多相关文章
- [ACM训练] ACM中巧用文件的输入输出来改写acm程序的输入输出 + ACM中八大输入输出格式
ACM中巧用文件的输入输出来改写acm程序的输入输出 经常有见大神们使用文件来代替ACM程序中的IO,尤其是当程序IO比较复杂时,可以使自己能够更专注于代码的测试,而不是怎样敲输入. C/C++代码中 ...
- c++ --> cin和cout输入输出格式
cin和cout输入输出格式 Cout 输出 1>. bool型输出 cout << true <<" or " << false < ...
- C语言第一次作业——输入输出格式
题目1温度转换 本题要求编写程序,计算华氏温度150°F对应的摄氏温度.计算公式:C=5×(F−32)/9,式中:C表示摄氏温度,F表示华氏温度,输出数据要求为整型. 1.实验代码 #include& ...
- hdu ACM Steps Section 1 花式A+B 输入输出格式
acm与oi很大的一个不同就是在输入格式上.oi往往是单组数据,而acm往往是多组数据,而且题目对数据格式往往各有要求,这8道a+b(吐槽..)涉及到了大量的常用的输入输出格式.https://wen ...
- POJ数据的输入输出格式
POJ在评阅习题时需要向程序提供输入数据,并获取程序的输出结果.因此提交的程序需按照每个习题具体的输入输出格式要求处理输入输出.有的时候,测评系统给出程序的评判结果是“数据错误”或“结果错误”,有可能 ...
- Hadoop MapReduce常用输入输出格式
这里介绍MapReduce常用的几种输入输出格式. 三种常用的输入格式:TextInputFormat , SequenceFileInputFormat , KeyValueInputFormat ...
- Hadoop(七):自定义输入输出格式
MR输入格式概述 数据输入格式 InputFormat. 用于描述MR作业的数据输入规范. 输入格式在MR框架中的作用: 文件进行分块(split),1个块就是1个Mapper任务. 从输入分块中将数 ...
- Hadoop学习之常用输入输出格式总结
目的 总结一下常用的输入输出格式. 输入格式 Hadoop可以处理很多不同种类的输入格式,从一般的文本文件到数据库. 开局一张UML类图,涵盖常用InputFormat类的继承关系与各自的重要方法(已 ...
- C语言输入输出格式符
C语言输入输出格式符 printf函数(格式输出函数) 1.一般格式 printf(格式控制,输出表列) 例如:printf("i=%d,ch=%c\n",i,ch); 说明: ( ...
随机推荐
- Valentine's Day Round hdu 5176 The Experience of Love [好题 带权并查集 unsigned long long]
传送门 The Experience of Love Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Ja ...
- Codeforces Round #291 (Div. 2) C. Watto and Mechanism [字典树]
传送门 C. Watto and Mechanism time limit per test 3 seconds memory limit per test 256 megabytes input s ...
- laravel 查询构造器
//查询构造器public function query(){ $bool = DB::table('student')->insert([ ['name' => '王五', 'age' ...
- saltstack 开发相关命令记录
SALT API开发相关命令记录. 查看当前的salt key信息salt-key -L 测试被控主机的连通性salt '*' test.ping 远程命令执行测试salt '*' cmd.run ' ...
- 2017 ACM/ICPC 广西邀请赛 题解
题目链接 Problems HDOJ上的题目顺序可能和现场比赛的题目顺序不一样, 我这里的是按照HDOJ的题目顺序来写的. Problem 1001 签到 #include <bits/std ...
- 非旋转Treap:用运行时间换调试时间的有效手段
非旋转Treap:用运行时间换调试时间的有效手段 Hello大家好,我们今天来聊一聊非旋转Treap. 相信各位或多或少都做过些序列上的问题.如果水题我们考虑暴力:不强制在线我们可能用过莫队和待修 ...
- Idea Failed to read artifact descriptor for xx:jar:unknown
网上的解决方案: 根据网上说明添加了maven命令clean compile install -Dmaven.test.skip=true,与我遇到的问题不同 有的方法猜测可以通过,但是没时间测试了 ...
- C# 把控件内容导出图片
Bitmap newbitmap = new Bitmap(panelW.Width, panelW.Height); panelW.DrawToBitmap(newbitmap ...
- how to avoid over-fitting?(机器学习中防止过拟合的方法,重要)
methods to avoid overfitting: Cross-Validation : Cross Validation in its simplest form is a one roun ...
- 转:NetBeans的远程Linux C开发实践
转: http://blog.csdn.net/jacktan/article/details/9268535 一直以来总觉得NetBeans生活在Eclipse的阴影下,同样做为一款不错的基于Jav ...