第一次在TopCoder上做题

今天是第一次在TopCoder上做题,本来今天有SRM481的比赛的。不过我注册时已经截至了。
晚上在赵牛的帮助下,弄了半天才注册上。
先是一大堆的注册相关信息,但是注册完后半天没有收到注册邮件,在赵牛的提醒下,才发现,居然没TX当成垃圾邮件了。。。然后又是电脑本地没JAVA,于是赵牛给我传了一个JDK,接着就是下载安装TopCoder Arena了。。。

注册一路真实坎坷的。。。不过还好,终于注册上了,打开TC,幽黑的背景,灵异的绿色,有点。。。恐怖哈。
于是自己找了一个练习场试试.
今天我学到了几点:
SRM,经常听别人说,现在终于知道了是 Single Round Match的简写。
因为是基于java的,不能右键点击赋值,只能Ctrl+C复制 和 Ctrl + V 粘贴。
在练习场我选择了SRM480的DIV2,因为250的题目最简单,所以直接做了这题,题目是让写一个类,基本上没什么思想,就是sort排序,然后long long类型的数相乘即可。

因为今天是第一次在TC上做题目,也是做的第一题,所提把题目和代码都贴出来,纪念下,顺便截几张图。

Problem Statement

TopCoder Security Agency (TSA, established today) has just invented a new encryption system! This encryption system takes as its input a list of numbers to encrypt. You work at TSA and your task is to implement a very important part of the encryption process. You are allowed to pick one number in the input list and increment its value by 1. This should be done in such way that the product of all numbers in the list after this change becomes as large as possible. Given the list of numbers as vector numbers, return the maximum product you can obtain. It is guaranteed that the return value will not exceed 2^62.

Definition

Class: Cryptography
Method:encrypt
Parameters:vector
Returns:long long

Method signature:long long encrypt(vector numbers)

(be sure your method is public)

Constraints


numbers will contain between 2 and 50 elements, inclusive.

Each element of numbers will be between 1 and 1000, inclusive.

The return value will not exceed 2^62.

Examples

0)
{1,2,3}

Returns: 12

If we increment the first number, we get 2*2*3 = 12. If we increment the second, we get 1*3*3 = 9. If we increment the third, we get 1*2*4 = 8. Hence, the correct return value is 12.

1)
{1,3,2,1,1,3}

Returns: 36

The elements of numbers are not necessarily unique.

2)
{1000,999,998,997,996,995}

Returns: 986074810223904000

The answer may be very big, but will not exceed 2^62.

3)
{1,1,1,1}

Returns: 2

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.

这是我的代码:

1
XXXX

我在TopCoder上做的第一题。

发布者

Tanky Woo

Tanky Woo,[个人主页:https://tankywoo.com] / [新博客:https://blog.tankywoo.com]

《第一次在TopCoder上做题》有6个想法

发表评论

电子邮件地址不会被公开。 必填项已用*标注