HDU 多校1.5

Expectation Division

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0
Special Judge

Problem Description

To be frank with you, this problem is a classic problem of tremendous magnitude which may increase the difficulty of this problem.

We define a type of operation concerning a positive integer n

(n>1)

as to replace it with an integer d

, one of factors of n

(1≤d≤n)

.

You are given a positive integer n

and then we will ask you to determine the expectation number of times to utilize this type of operation if we want to change n

into 1

by operating again and again, assuming each possible d

in each operation has equal possibility to select.

For the sake of calculation, n

and all its distinct prime factors p1,p2,?,pm

will be given, satisfying n

has m

distinct prime factors exactly.

Input

The input contains multiple test cases.

For each test case:

The first line contains two positive integers n

and m

which indicates m

is the number of distinct prime factors of n

, satisfying 2≤n≤1024

.

The second lines contains m

distinct prime numbers p1,p2,?,pm

, satisfying 2≤pi≤106

.

About 2⋅105

test cases in total.

Warm Tips for C/C++: __int128_t is available here but standard solutions of this problem do not use this compiler-dependent data type.

Output

For each test case, output "Case #x

: y

" in one line (without quotes), where x

indicates the case number starting from 1

and y

denotes the expectation number of times to utilize this type of operation of corresponding case. Your answer will be considered correct if its absolute or relative error won‘t exceed 10−9

.

Sample Input

2 1
2
4 1
2
6 2
2 3
8 1
2
10 2
2 5
12 2
2 3

Sample Output

Case #1: 2.0000000000
Case #2: 2.5000000000
Case #3: 2.6666666667
Case #4: 2.8333333333
Case #5: 2.6666666667
Case #6: 3.0333333333

时间: 2024-11-28 21:47:58

HDU 多校1.5的相关文章

2015 HDU 多校联赛 5317 RGCDQ 筛法求解

2015 HDU 多校联赛 5317 RGCDQ 筛法求解 题目  http://acm.hdu.edu.cn/showproblem.php? pid=5317 本题的数据量非常大,測试样例多.数据量大, 所以必须做预处理.也就是用筛法求出全部的F[x],将全部F[x] 打印出来发现.事实上结果不大,最大的数值是7.所以对于每一个区间询问, 直接暴力求取有多少个 1 2 3 4 5 6 7 就可以,从大到小查找.假设出现2个以上 3-7 的数值,那么最大公约数就是该数字. 假设没有出现两个反复

HDU多校赛第9场 HDU 4965Fast Matrix Calculation【矩阵运算+数学小知识】

难度上,,,确实,,,不算难 问题是有个矩阵运算的优化 题目是说给个N*K的矩阵A给个K*N的矩阵B(1<=N<=1000 && 1=<K<=6),先把他们乘起来乘为C矩阵,然后算C^(N*N) 相当于 ABABABABABABAB...=(AB)^(N*N) 不如 A(BA)^(N*N-1)B 因为BA乘得K*K的矩阵,K是比较小的 #include <cstdio> #include <cstdlib> #include <cstr

2014 HDU多校弟八场H题 【找规律把】

看了解题报告,发现看不懂 QAQ 比较简单的解释是这样的: 可以先暴力下达标,然后会发现当前数 和 上一个数 的差值是一个 固定值, 而且等于当前数与i(第i个数)的商, 于是没有规律的部分暴力解决,有规律的套公式 //#pragma comment(linker, "/STACK:16777216") //for c++ Compiler #include <stdio.h> #include <iostream> #include <cstring&g

2015 HDU 多校联赛 5326 Work

2015 HDU 多校联赛 5326 Work 题目: http://acm.hdu.edu.cn/showproblem.php?pid=5326 这题应该是本周二多校赛中,最简单的一道题目了. 解题思路: 就是回根. 用一个数组 root[i] = j 表示 i 的上级是 j , 对于每个输入的关系都做这样的处理.然后遍历每个编号直到root[i] 的结果为0 (因为根没有上级,所以根为0),在往根回退的过程中,用一个数组 cnt[i] 表示经过i这个点的次数. 最后就是遍历 cnt[i],

2014 HDU多校弟九场I题 不会DP也能水出来的简单DP题

听了ZWK大大的思路,就立马1A了 思路是这样的: 算最小GPA的时候,首先每个科目分配到69分(不足的话直接输出GPA 2),然后FOR循环下来使REMAIN POINT减少,每个科目的上限加到100即可 算最大GPA的时候,首先每个科目分配到60分,然后FOR循环下来使REMAIN POINT减少,每个科目的上限加到85即可,如果还有REMAIN POINT,就FOR循环下来加到100上限即可 不会DP 阿 QAQ 过段时间得好好看DP了  =  = 于是默默的把这题标记为<水题集> //

2015 HDU 多校联赛 5363 Key Set

2015 HDU 多校联赛 5363 Key Set 题目: http://acm.hdu.edu.cn/showproblem.php?pid=5363 根据前面给出的例子,得出求解公式 fn = 2^(n-1) - 1, 数据量大,实际就是求幂次方. 可用分治法求解,复杂度O(nlogn) // 分治法求快速幂 #include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; const int MO

2014 HDU多校弟五场J题 【矩阵乘积】

题意很简单,就是两个大矩阵相乘,然后求乘积. 用 Strassen算法 的话,当N的规模达到100左右就会StackOverFlow了 况且输入的数据范围可达到800,如果变量还不用全局变量的话连内存开辟都开不出来 1 #pragma comment(linker, "/STACK:16777216") 2 #include <iostream> 3 #include <stdio.h> 4 #define ll long long 5 using namesp

2014 HDU多校弟五场A题 【归并排序求逆序对】

这题是2Y,第一次WA贡献给了没有long long 的答案QAQ 题意不难理解,解题方法不难. 先用归并排序求出原串中逆序对的个数然后拿来减去k即可,如果答案小于0,则取0 学习了归并排序求逆序对的方法,可以拿来当模板 TVT 贴代码了: 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <math.h> 5 #include <iostream&g

Wow! Such Sequence! HDU多校联合赛第三场1007

Wow! Such Sequence! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description Recently, Doge got a funny birthday present from his new friend, Protein Tiger from St. Beeze College. No, not cactuses. It's

HDU多校联合赛(1007 Magical Forest)模拟题

题目: Problem Description There is a forest can be seen as N * M grid. In this forest, there is some magical fruits, These fruits can provide a lot of energy, Each fruit has its location(Xi, Yi) and the energy can be provided Ci. However, the forest wi