## TLE '16 Contest 6 (Mock CCC) J2 - Carol's Flowers

View as PDF

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Mr. C has had a change of heart from being a lonely developer to finally getting a girlfriend, Ms. C (they are not related by blood). As the courteous fellow he is, he has decided to buy some flowers for her.

Ms. C wants flowers with flower costing , a positive integer. The store, Carol's Flowers, has flowers, where . Each flower can only be bought once, and since Mr. C lives in a computer science problem, the cost of the flowers are exponential. In other words, the second flower he buys is the price of the flower squared, and the third flower he buys is the price of the flower cubed, and so on.

Mr. C is poor, but he needs to satisfy Ms. C. Can you find out the minimum value Mr. C has to pay for flowers?

#### Input Specification

The first line of input contains integers, and ().

The next lines contain integer each. The line contains the positive integer ().

• For 5 of the 15 available marks, and .
• For an additional 5 of the 15 available marks, and .

#### Output Specification

A single integer representing the minimum price Mr. C has to pay for flowers mod ().

#### Sample Input

7 3
2
5
2
9
100
56
3

#### Sample Output

15

#### Explanation for Sample Output

The cheapest way to buy flowers is to buy the last flower, the third flower, and the first flower. That is, is the minimum price.

• commented on Jan. 19, 2018, 8:49 p.m.

I got only the first case right

• commented on Feb. 20, 2017, 9:16 p.m.

Where would we input i?

• commented on Jan. 19, 2018, 6:04 p.m.

sad to find that nobody replied to your comment in 1 whole year.

• commented on Feb. 20, 2017, 12:10 p.m.

if the price of the sum of the flowers are more expensive than the sum in c's wallet, should I mod the sum(of the flowers)?

• commented on Feb. 20, 2017, 12:15 p.m.

The wallet has nothing to do with this problem. It has been removed from the problem description to prevent confusion.

Sorry for any inconvenience this may have caused.