CF656B.Scrambled

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:64MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Btoh yuo adn yuor roomatme lhoate wianshg disehs, btu stlil sdmoeboy msut peorrfm tihs cohre dialy. Oen dya yuo decdie to idourtcne smoe syestm. Yuor rmmotaoe sstgegus teh fooniwllg dael. Yuo argee on tow arayrs of ientgres M adn R, nmebur upmicnog dyas (induiclng teh cunrret oen) wtih sicsescuve irnegets (teh ceurrnt dya is zreo), adn yuo wsah teh diehss on dya D if adn olny if terhe etsixs an iednx i scuh taht D mod M[i] = R[i], otwsehrie yuor rmootmae deos it. Yuo lkie teh cncepot, btu yuor rmotaome's cuinnng simle meaks yuo ssecupt sthnoemig, so yuo itennd to vefriy teh fnerisas of teh aemnrgeet.

Yuo aer geivn ayarrs M adn R. Cuaclatle teh pceanregte of dyas on wchih yuo edn up dnoig teh wisahng. Amsuse taht yuo hvae iiiftlneny mnay dyas aehad of yuo.

你和你的室友轮流洗碗,但仍然需要有人每天执行这项任务。某天,你们决定引入一种系统。你的室友提出了以下方案:你们约定两个整数数组 MM 和 RR,以及一个表示“即将到来的天数”(包括当天)的数组,其中天数用连续整数编号(当天编号为 00);并且你们在第 DD 天洗碗,当且仅当存在某个下标 ii,使得

D mod M[i]=R[i],D \bmod M[i] = R[i],

否则你的室友来洗。你很喜欢这个想法,但你室友那狡黠的微笑让你心生疑虑,因此你打算验证该协议的细节。

现给你数组 MM 和 RR。请计算在所有天数中,你最终需要洗碗的天数所占的比例(即概率)。假设你面前有无限多的天数。

输入格式

The first line of input contains a single integer N (1 ≤ N ≤ 16).

The second and third lines of input contain N integers each, all between 0 and 16, inclusive, and represent arrays M and R, respectively. All M[i] are positive, for each i R[i] < M[i].

输入的第一行包含一个整数 $ N (( 1 \leq N \leq 16 $)。

输入的第二行和第三行各包含 $ N $ 个整数,所有整数均在 $ 0 $ 到 $ 16 $ 之间(含端点),分别表示数组 $ M $ 和 $ R $。对每个 $ i $,均有 $ M[i] > 0 $,且 $ R[i] < M[i] $。

输出格式

Output a single real number. The answer is considered to be correct if its absolute or relative error does not exceed 10 - 4.

输出一个实数。若答案的绝对误差或相对误差不超过 10−410^{-4},则视为正确。

输入输出样例

  • 输入#1

    1
    2
    0

    输出#1

    0.500000
  • 输入#2

    2
    2 3
    1 0

    输出#2

    0.666667

输入解题思路,AI测评打分。不知道怎么写?

首页