You are on page 1of 2

14/11/13

Problem - C - Codeforces

Enter | Register
Sponsored by

HOME
PROBLEMS

CONTESTS
SUBMIT

GYM PROBLEMSET RATING


YANDEX.ALGORITHM 2013

MY SUBMISSIONS

STATUS

HACKS

ROOM

STANDINGS

HELP

ABBYY CUP 3.0

Se arch by tag

CUSTOM TEST

Codeforces Round #209 (Div. 2)

C. Prime Number

Finished

time limit per test: 1 second


memory limit per test: 256 megabytes
input: standard input
output: standard output
Simon has a prime number

Practice?
Want to solve the contest problems after the
official contest ends? Just register for
practice and you will be able to submit
solutions.

x and an array of non-negative integers a1,a2,...,an.

Simon loves fractions very much. Today he wrote out number

on a

piece of paper. After Simon led all fractions to a common denominator and summed them up,
he got a fraction: , where number t equals xa 1+a 2+...+a n. Now Simon wants to reduce the
resulting fraction.
Help him, find the greatest common divisor of numbers s and t. As GCD can be rather large,
9
print it as a remainder after dividing it by number 1000000007 (10 +7).

Input
The first line contains two positive integers n and
the array and the prime number.

ACM-ICPC WF-2013

x (1n105, 2x109) the size of

Register for practice

Problem tags
math
No tag edit access

Contest materials
Announcement

The second line contains n space-separated integers a1,a2,...,an (0a1a2...an


109).

Output
Print a single number the answer to the problem modulo

1000000007 (109+7).

Sample test(s)

input
22
22

output
8

input
33
123

output
27

input
22
29 29

output
73741817

input
45
0000

file:///F:/INFORMTICA/ACM/Codeforces/Problemitas/Prime number.html

1/2

14/11/13

Problem - C - Codeforces

output
1

Note
In the first sample
In the second sample,

. Thus, the answer to the problem is 8.


. The answer to the problem is 27,

as 351=1327, 729=2727.
In the third sample the answer to the problem is 1073741824
73741817.
In the fourth sample

mod 1000000007=

. Thus, the answer to the problem is 1.

Codeforces (c) Copyright 2010-2013 Mike Mirzayanov


The only programming contests Web 2.0 platform
Server time: 11/07/2013 07:30AM (p1).

file:///F:/INFORMTICA/ACM/Codeforces/Problemitas/Prime number.html

2/2

You might also like