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只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...
随机推荐
- 在CentOS 7 上搭建LAMP
导读 要求:httpd的动态和静态资源分为两台主机提供,mysql也用单独一台主机.httpd服务提供虚拟主机,一个虚拟主机用于提供phpMyAdmin:另一个虚拟主机用于提供wordpress.安装 ...
- Unity 3D 粒子系统的一点经验
http://hunterwang.diandian.com/post/2012-10-21/40041523890 最近做东西需要增加效果,简单的运用了一下粒子效果,真心感觉比较难调整好效果.同时也 ...
- Windows/Centos安装GO语言环境
转载:http://www.haiyun.me/archives/1009.html Centos下使用epel源安装: 1 yum install golang Centos/Linux下源码安装g ...
- 10 Python Optimization Tips and Issues
转自: http://www.algorithm.co.il/blogs/computer-science/10-python-optimization-tips-and-issues/
- 【Hibernate】Hibernate系列1之概述
概述 Hibernate简介 1.2.安装hibernate tools插件 1.3.HelloWorld示例 1.3.1.加入jar包 1.3.2.开发步骤 hibernate generator ...
- Unique Paths | & ||
Unique Paths I A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diag ...
- Ubuntu安装steam游戏平台的解决方案
steam是一个游戏平台,上面提供了很多收费和免费的游戏,在安装的过程中遇到了一些问题,所以把自己遇到的问题及解决方案分享出来供大家参考. 第一步:安装steam平台 sudo apt-get ins ...
- 昂贵的聘礼(poj 1062)
Description 年轻的探险家来到了一个印第安部落里.在那里他和酋长的女儿相爱了,于是便向酋长去求亲.酋长要他用10000个金币作为聘礼才答应把女儿嫁给他.探险家拿不出这么多金币,便请求酋长降低 ...
- (六)STM32的时钟系统
在STM32中,一共有5个时钟源,分别是HSI.HSE.LSI.LSE.PLL (1) HSI是高速内部时钟,RC振荡器,频率为8MHz: (2) HSE是高速外部时钟,可接石英/陶瓷谐振器,或者接外 ...
- Hadoop 中文编码相关问题 -- mapreduce程序处理GBK编码数据并输出GBK编码数据(转)
hadoop的hdfs文件系统中,默认的是utf-8, 故你上传的文件是要设置成utf-8.当输入的是gbk,有该如何? 输入是GBK文件, 输出也是 GBK 文件的示例代码: Hadoop处理GBK ...