Hacker cup 2013 final problem 4

Topics here are only Rebol 2 related

Hacker cup 2013 final problem 4

Postby MaxV on Thu May 16, 2013 10:00 am

Rebol is admintted as language in Hacker cup 2013! Can you solve this problem?

Your house has 2 ≤ N ≤ 500,000 distinct rooms. None of the rooms have doors, but every room has a one way teleport which takes you to a different room. The same teleport will always go to the same room. You want to make sure that every room can be reached from every room, via a series of teleports. To do this, you are allowed to change the destination of some (or all) of the teleports.

What is the sum of the minimum number of teleports you have to change to achieve this, over all possible different starting configurations? Two starting configurations are different if for some room, the outgoing teleport goes to different rooms in the two configurations.

Input

The first line contains a single integer T, T ≤ 20. T test cases follow, where each test case consists of one integer: N

Input is a simple TXT (uncompress it):
teleports.zip
(235 Bytes) Downloaded 26 times


Output

Output one single line with the sum of the minimum number of teleports you have to change over all possible different starting configurations. Since this number might be very big, output it modulo 1,000,000,007

Examples
Example input


Code: Select all
5
2
3
5
10
20


Example output
Code: Select all
Case #1: 0
Case #2: 6
Case #3: 1720
Case #4: 435035973
Case #5: 93930085
User avatar
MaxV
 
Posts: 104
Joined: Tue Jan 22, 2013 12:04 pm
Location: Italy

Re: Hacker cup 2013 final problem 4

Postby bogger on Sat Jan 17, 2015 2:29 am

You got your point! and i want intruduce a nice game







______________________
More Exciting News Fifa 15 News Site are Waiting For You.
bogger
 
Posts: 3
Joined: Sat Jan 17, 2015 2:16 am

Re: Hacker cup 2013 final problem 4

Postby lee520 on Fri Apr 10, 2015 7:45 am

<P></P>
<P>Shots on goal was even as well with 26 shots for each Cheap Polo Ralph Lauren team. Hache played in nets for Cheap Polo Ralph Lauren Shirts Bluewave, and Stephen Pugsley played in goal for J 14 point to the score box extends Polo Ralph Lauren Factory Outlet Cormier's Polo Ralph Lauren Kids lead in the scoring race to 75 points, 16 points ahead of second place Justin Matthews. Cormier has 35 goals and 40 assists, and Matthews has 28 goals and 31 assists.</P>
lee520
 
Posts: 2
Joined: Fri Apr 10, 2015 7:40 am


Return to Rebol 2

Who is online

Users browsing this forum: No registered users and 1 guest

cron