分类目录归档:map

Codeforces Round#274 Div.2

A. Expression

Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of operations '+' and '*', and probably brackets between the numbers so that the value of the resulting expression is as large as possible. Let's consider an example: assume that the teacher wrote numbers 1, 2 and 3 on the blackboard. Here are some ways of placing signs and brackets:

  • 1+2*3=7
  • 1*(2+3)=5
  • 1*2*3=6
  • (1+2)*3=9

Note that you can insert operation signs only between a and b, and between b and c, that is, you cannot swap integers. For instance, in the given sample you cannot get expression (1+3)*2.

It's easy to see that the maximum value that you can obtain is 9.

Your task is: given a, b and c print the maximum value that you can get. 继续阅读

[bzoj 1054][HAOI2008] 移动玩具

Description

  在一个4*4的方框内摆放了若干个相同的玩具,某人想将这些玩具重新摆放成为他心中理想的状态,规定移动时只能将玩具向上下左右四个方向移动,并且移动的位置不能有玩具,请你用最少的移动次数将初始的玩具状态移动到某人心中的目标状态。

继续阅读

AOJ Challenge Problems 1

Anagrammatic Primes

A number is "prime" if it has no divisors other than itself and 1. For example, 23 is prime but 35 is not prime because 35 = 7 x 5. If the digits of a number are rearranged, then usually its primeness changes — for example, 35 is not prime but 53 is. For this problem, you must find numbers which are prime no matter how you rearrange their digits. For example, all of the numbers 113, 131 and 311 are prime, so we say that 113 is an "anagrammatic prime" (also 131 and 311 are anagrammatic primes).

继续阅读

CodeForces Round #350 Solution

这场比赛比较水,但是细节比较多,而我没考虑T_T

一个是先入为主坑了我的B题,我没有计算时间复杂度而导致采用了较繁而且容易挂的算法,wa了4发

C题是因为我没能考虑到特殊情况而苦于wa on 14,7 times

如果没有这两个错误说不定能大涨分= =

这些错误都是值得我思考以及改正的,好了,切入正题

继续阅读