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); 说明: ( ...
随机推荐
- POJ3132 Sum of Different Primes
Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 3473 Accepted: 2154 Description A pos ...
- hdu 4952
Number Transformation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Ot ...
- HDU 4771 BFS + 状压
Stealing Harry Potter's Precious Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 ...
- 标准C程序设计七---22
Linux应用 编程深入 语言编程 标准C程序设计七---经典C11程序设计 以下内容为阅读: <标准C程序设计>(第7版) 作者 ...
- mysqldumpslow不是内部或外部命令,也不是可运行的程序
mysqldumpslow不是内部或外部命令,也不是可运行的程序 window系统,mysql版本:5.7.14. 使用mysqldumpslow命令分析日志时,报错:mysqldumpslow'不是 ...
- 531. Lonely Pixel I
Given a picture consisting of black and white pixels, find the number of black lonely pixels. The pi ...
- Jenkins使用Publish Over FTP Plugin插件上传FTP详解
一.安装插件[Publish Over FTP] 二.在[系统管理]->[系统设置]->[Publish over FTP]->点击[增加]按钮,增加一个要连接的FTP: FTP S ...
- SD卡读写之FileNotFoundException: /storage/emulated/0object.txt: open failed: ENOENT (No such file or dir
读写sd卡中的文件依照例如以下步骤:1调用Environment的getExternalStorageState()方法推断手机上是否插入了sd卡.而且应用程序具有读写SD卡的能力 //假设手机已经插 ...
- hdu5289(2015多校1)--Assignment(单调队列)
Assignment Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total ...
- max-points-on-a-line——穷举
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. ...