B. Scrambled

题目连接:

http://www.codeforces.com/contest/656/problem/B

Description

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.

Input

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

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

Sample Input

1

2

0

Sample Output

0.500000

Hint

题意

听说改变文字顺序,并不影响题目阅读 hhh

就是两个人洗碗的故事,如果对于i天来说,存在一个j,使得i%m[j]=r[j]

那么这一天归我洗碗,否则归他

问一共百分之多少的天数,我在洗碗。

题解:

算个lcm,然后直接暴力就好了

1到16的lcm是720720

代码

#include<bits/stdc++.h>
using namespace std;
const int maxn = 20; int m[maxn],r[maxn];
int main()
{
int n;scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d",&m[i]);
for(int i=1;i<=n;i++)scanf("%d",&r[i]);
int ans1=1;
for(int i=0;i<=720720;i++)
for(int j=1;j<=n;j++)
if(i%m[j]==r[j]){ans1++;break;}
printf("%.10f\n",1.0*ans1/(1.0*720720));
}

April Fools Day Contest 2016 B. Scrambled的更多相关文章

  1. April Fools Day Contest 2016 D. Rosetta Problem

    D. Rosetta Problem 题目连接: http://www.codeforces.com/contest/656/problem/D Description ++++++++[>+& ...

  2. April Fools Day Contest 2016 G. You're a Professional

    G. You're a Professional 题目连接: http://www.codeforces.com/contest/656/problem/G Description A simple ...

  3. April Fools Day Contest 2016 F. Ace It!

    F. Ace It! 题目连接: http://www.codeforces.com/contest/656/problem/F Description Input The only line of ...

  4. April Fools Day Contest 2016 E. Out of Controls

    E. Out of Controls 题目连接: http://www.codeforces.com/contest/656/problem/E Description You are given a ...

  5. April Fools Day Contest 2016 C. Without Text 信号与系统

    C. Without Text 题目连接: http://www.codeforces.com/contest/656/problem/C Description You can preview th ...

  6. April Fools Day Contest 2016 A. Da Vinci Powers

    A. Da Vinci Powers 题目连接: http://www.codeforces.com/contest/656/problem/A Description The input conta ...

  7. CF #April Fools Day Contest 2016 E Out of Controls

    题目连接:http://codeforces.com/problemset/problem/656/E 愚人节专场的E,整个其实就是个Floyd算法,但是要求代码中不能包含 definedoforfo ...

  8. April Fools Day Contest 2014

    April Fools Day Contest 2014 A.C.H三道题目 ============================================================= ...

  9. 坑爹CF April Fools Day Contest题解

    H - A + B Strikes Back A + B is often used as an example of the easiest problem possible to show som ...

随机推荐

  1. git命令大全【转】

    转自:http://www.jqhtml.com/8235.html 初始化本地git仓库(创建新仓库) git init 配置用户名 git config --global user.name &q ...

  2. ELK&ElasticSearch5.1基础概念及配置文件详解【转】

    1. 配置文件 elasticsearch/elasticsearch.yml 主配置文件 elasticsearch/jvm.options jvm参数配置文件 elasticsearch/log4 ...

  3. spring-mybatis.xml配置

    1.自动扫描 <context:component-scan base-package="com.javen" /> 2.引入配置文件 <bean id=&quo ...

  4. Linux删除除了今天以外的文件

    [背景] 开发到日志记录功能时,每天都会产生当天的一个日志,久而久之就会产生累积,想要查看的时候,tab键无法自动补全,还要自己额外输入. 比较麻烦. [命令] 经过查找和实验,找到了以下的方法: 1 ...

  5. docker简单介绍(资料收集总结)

    [前言] 首先,感谢我的leader总是会问我很多技术的基本资料,让我这个本来对于各种技术只知道操作命令不关注理论知识的人,开始重视理论资料. 关于docker的操作步骤等等,都是之前学习的,现在补上 ...

  6. charles抓包误点deny处理办法及日常抓包

    误点deny方法在最底下~~ (博文为转载) 我们在开发网站项目的时候,我们可以通过浏览器的debug模式来看request以及response的数据,那么如果我们开发移动端项目没有网页呢?如何抓取数 ...

  7. svm和svr区别--摘自其它博客

    学习笔记:SVM柔性边界的补充和SVR(支持向量回归) 作者 小刺猬yyx 关注 2016.08.06 10:31* 字数 1608 阅读 421评论 0喜欢 2 上一个笔记对于SVM不能完美分类的情 ...

  8. spring源码分析---事务篇

    上一篇我介绍了spring事务的传播特性和隔离级别,以及事务定义的先关接口和类的关系.我们知晓了用TransactionTemplate(或者直接用底层P的latformTransactionMana ...

  9. MYSQL-----流程控制 if() 函数的用法

    语法:IF(condition,result,result) 如果函数的第一个参数中给定的condition符合条件(如,condition不等于0或者不为NULL),那么函数的执行结果为第二个参数中 ...

  10. Fresco 获得Bitmap

    ImageRequest imageRequest = ImageRequestBuilder .newBuilderWithSource( Uri.parse(getFeedItem(positio ...