2018焦作 Gym - 102028E - Resistors in Parallel 【乱搞】

In this physics problem, what we are concerned about are only resistors. If you are poor at physics, do not worry, since solving this problem does not require you to have advanced abilities in physics.

Resistors are said to be connected together in parallel when both of their terminals are respectively connected to each terminal of the other resistors.

We have the following parallel resistor equation for k resistors with resistances R1, R2, ..., Rk in parallel and their combined resistance R:

Now you have n resistors, the i-th of which has a resistance of ri ohms with the equation

You also have n selections, the i-th of which is a set of resistors Si such that

Please find a selection in which the resistors form a parallel resistor with the minimum resistance and output the reduced fraction  of its resistance.

Input

The input contains several test cases, and the first line contains a positive integer T indicating the number of test cases which is up to 100.

For each test case, the only one line contains an integer n, where 1 ≤ n ≤ 10100.

Output

For each test case, output a line containing a reduced fraction of the form p/qindicating the minimum possible resistance, where p and q should be positive numbers that are coprime.

 

 

分析:通过手动打表得出,最小值分别在1,1*2,1*2*3,1*2*3*5,1*2*3*5*7。。。得到。

分子即使连续的素数乘积,分母是分子的全部因子之和(公式)。

由于要用到高精度,直接用java会比较好写。

//package ac;
import java.math.*;
import java.util.*;;
public class Main {
public static void main(String[] args) {
        boolean[] vis=new boolean[10004];
        int [] prim = new int[10004];
        int cnt=0;
        for(int i=2;i<10004;++i)
        {
            if(!vis[i])prim[cnt++]=i;
            for(int j = 0;j

 

你可能感兴趣的:(2018焦作 Gym - 102028E - Resistors in Parallel 【乱搞】)