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

PSO

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 515    Accepted Submission(s): 255


Problem Description
Particle swarm optimization ( PSO ) is a population-based stochastic optimization algorithm. In addition to the basic structure of PSO, there is also a variant called star-topology PSO, which introduces a star-shaped communication structure among particles. In this structure, there is a central particle called the leader, which is responsible for gathering and disseminating information to the rest of the particles in the swarm.

Now there are $n$ particles on the star-topology. Among the $n$ particles, there is one particle as the leader, and there is an edge between the other particles and the leader. For a piece of information, it can be propagated along an edge on the topology.


To examine the benefits of this topology, we need to calculate the following data:

We define that $X$ is number of edges required for them to exchange information for two different particles. Please calculate the expected value and maximum value of $X$.
 

Input
The first line of input is a positive integer $T(T\leq 10^5)$ representing the number of test cases.

For each line,input a number $n(2\leq n\leq10^9)$.
 

Output
For each case, output two floating-point numbers representing the he expected value rounde off and maximum value of $X$. (keep $9$ decimal places)
 

Sample Input
2 4 7
 

Sample Output
1.500000000 2.000000000 1.714285714 2.000000000
 

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-11-22 16:25:24, Gzip enabled