CodeForces 656B
Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
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 iR[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
0.500000
2
2 3
1 0
0.666667 这是一道水题,题目不好懂。
#include<bits/stdc++.h>
#define day 1000000
using namespace std;
int main()
{
int m[];
int n[];
int num;
scanf("%d",&num);
for(int i=;i<num;i++)
scanf("%d",&m[i]);
for(int i=;i<num;i++)
scanf("%d",&n[i]);
double ans=0.0;
for(int d=;d <day;d++)
{
for(int i=;i<num;i++)
{
if(d%m[i]==n[i]) {ans++;break;}
}
}
printf("%lf\n",ans/day);
return ;
}
CodeForces 656B的更多相关文章
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
- CodeForces - 696B Puzzles
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
- CodeForces - 148D Bag of mice
http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...
随机推荐
- <转>错误 x error LNK1104: 无法打开文件“E:\xxxx\Debug\xxxx.exe”
刚刚还好好的,怎么突然就出现这样的错误, 后来分析原因, 第一:查看那个exe文件是否存在, 第二:查看那个文件或者那个文件所在的文件夹是否打开或者改名字等等操作占用着这个文件. 第三:重新清理并生成 ...
- 提高php运行效率的50个技巧
1.如果能将类的方法定义成static,就尽量定义成static,它的速度会提升将近4倍. 2.并不是事必面向对象(OOP),面向对象往往开销很大,每个方法和对象调用都会消耗很多内存. 3.方法调用看 ...
- php面试题之二——数据结构和算法(高级部分)
二.数据结构和算法 1.使对象可以像数组一样进行foreach循环,要求属性必须是私有.(Iterator模式的PHP5实现,写一类实现Iterator接口)(腾讯) <?php class T ...
- Linux内核之数据双链表
导读 Linux 内核中自己实现了双向链表,可以在 include/linux/list.h 找到定义.我们将会首先从双向链表数据结构开始介绍内核里的数据结构.为什么?因为它在内核里使用的很广泛,你只 ...
- UIView中UIButton设置监听
红色框框是一个uibutton _priceValueLabel是他的父视图, 必须要把button的父视图设置userInteractionEnabled = YES, button的 监听才会生效 ...
- 在线调试和演示的前端开发工具------http://jsfiddle.net/
在线调试和演示的前端开发工具------http://jsfiddle.net/
- svn提交时强制添加注释 (转)
SVN提交时,如果没有注释,在查阅历史时,会非常不方便.因此我们需要有一个让程序员提交代码时,强制添加注释的规则.下面看看在SVN中怎么实现. 1. 推荐使用VisualSVN作为服务端(免费下载地址 ...
- openstack 前期准备工作
OS 是 centos6.5_X86_64 一.vmware 虚拟机 准备两台机虚拟机即可 二.导入第三方安装源 [root@openstack ~]# rpm -Uvh http://dl.fedo ...
- python 下载文件 & 防盗链
偶然下载一种类型的资源,发现好多翻页,右键另存什么的,不胜其烦. 决定用python写几句代码搞定.核心代码如下: from urllib import urlretrieve from urllib ...
- maven3 junit4 spring3 jdk8 :junit一直报错,害的我几个星期都是这个错,你妹的!
[org.springframework.test.context.junit4.SpringJUnit4ClassRunner]SpringJUnit4ClassRunner constructor ...