303380: CF656B. Scrambled

Memory Limit:64 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Scrambled

题意翻译

讨厌你和你的室友都洗盘子,去洗要有人但必须。提出了一个方案你的室友有一天。两个整数数组M和R你们协商,为即将到来的天数D连续整数(当前天数当前天数包括且为0),存在如果整数i满足D mod M[i] = R[i]则洗你盘子,洗盘子你的室友反之。这个喜欢方案你。狡猾的微笑看到你的室友但当你时,它的怀疑你公平性开始。M和R现给出,的可能性计算你洗盘子请编程(有无数天假设之后)。 输入格式: 第一行为N(1<=N<=16)。 第二行与第三行各有N个整数,各为数组M和R。 输出格式: 输出一个实数。如果答案的绝对值或相对误差不超过10^-4则答案正确。 感谢@leoli 提供的翻译 说明:这是CF出在愚人节的一道题,原题中的英文字母全为乱序。

题目描述

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.

输入输出格式

输入格式


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] $ .

输出格式


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

输入输出样例

输入样例 #1

1
2
0

输出样例 #1

0.500000

输入样例 #2

2
2 3
1 0

输出样例 #2

0.666667

说明

both you and roommate loathe washing dishes, but still somebody must perform this chore daily. One day you decide to introduce some system. Your roommate suggests the following deal. You agree on two arrays of integers M and R, number upcoming days (including the current one) with successive integers (the current day is zero), and you wash the dishes on day D if and only if there exists an index i such that D mod M[i]=R[i] ,otherwise your roommate does it. You like the concept, but your roommate’s cunning smile makes you suspect something, so you intend to verify the fairness of the agreement. You are given arrays M and R. Calculate the percentage of days on which you end up doing the washing. Assume that you have infinitely many days ahead of you.

Input

题意翻译

讨厌你和你的室友都洗盘子,去洗要有人但必须。提出了一个方案你的室友有一天。两个整数数组M和R你们协商,为即将到来的天数D连续整数(当前天数当前天数包括且为0),存在如果整数i满足D mod M[i] = R[i]则洗你盘子,洗盘子你的室友反之。这个喜欢方案你。狡猾的微笑看到你的室友但当你时,它的怀疑你公平性开始。M和R现给出,的可能性计算你洗盘子请编程(有无数天假设之后)。 输入格式: 第一行为N(1<=N<=16)。 第二行与第三行各有N个整数,各为数组M和R。 输出格式: 输出一个实数。如果答案的绝对值或相对误差不超过10^-4则答案正确。 感谢@leoli 提供的翻译 说明:这是CF出在愚人节的一道题,原题中的英文字母全为乱序。

加入题单

算法标签: