F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Minimal Spanning Tree

Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 523    Accepted Submission(s): 176


Problem Description
Given a connected, undirected, weight graph G, your task is to select a subset of edges so that after deleting all the other edges, the graph G is still connected. If there are multiple ways to do this, you should choose the way that minimize the sum of the weight of these selected edges.

Please note that the graph G might be very large. we'll give you two numbers: N, and seed, N is number of nodes in graph G, the following psuedo-code shows how to to generate graph G.



Here ¨’ represents bitwise xor (exclusive-or).
 

Input
Input contains several test cases, please process till EOF.
For each test case, the only line contains two numbers: N and seed.(1 ¡Ü N ¡Ü 10000000, 1 ¡Ü seed ¡Ü 2333332)
 

Output
For each test case output one number, the minimal sum of weight of the edges you selected.
 

Sample Input
6 2877 2 17886 3 22452
 

Sample Output
2157810 259637 1352144
 

Author
Fudan University
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-29 17:33:17, Gzip enabled