April Fools Day Contest 2016 B. Scrambled
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的更多相关文章
- April Fools Day Contest 2016 D. Rosetta Problem
		
D. Rosetta Problem 题目连接: http://www.codeforces.com/contest/656/problem/D Description ++++++++[>+& ...
 - 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 ...
 - 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 ...
 - 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 ...
 - April Fools Day Contest 2016 C. Without Text 信号与系统
		
C. Without Text 题目连接: http://www.codeforces.com/contest/656/problem/C Description You can preview th ...
 - 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 ...
 - CF #April Fools Day Contest 2016 E Out of Controls
		
题目连接:http://codeforces.com/problemset/problem/656/E 愚人节专场的E,整个其实就是个Floyd算法,但是要求代码中不能包含 definedoforfo ...
 - April Fools Day Contest 2014
		
April Fools Day Contest 2014 A.C.H三道题目 ============================================================= ...
 - 坑爹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 ...
 
随机推荐
- pycharm双击无响应,打不开问题解决办法
			
之前好好的pycharm,突然双击打不开了,怎么办? 亲测有效方案: 第一步:进入如下路径,找到cmd.exe,右键选择“以管理员身份运行”: 第二步:在打开的cmd窗口中,输入 netsh wins ...
 - caffe Python API 之Solver定义
			
from caffe.proto import caffe_pb2 s = caffe_pb2.SolverParameter() path='/home/xxx/data/' solver_file ...
 - PHP用imageTtfText函数在图片上写入汉字
			
https://blog.csdn.net/smstong/article/details/43955705 PHP绘图,imageString()这个函数并不支持汉字的绘制.这往往会给入门者当头一棒 ...
 - 获取AD用户名
			
var wshNetwork = new ActiveXObject("WScript.Network"); alert("域名 = "+ wshNetwork ...
 - 浅谈Linux系统中如何查看进程 ——ps,pstree,top,w,全解
			
进程是一个其中运行着一个或多个线程的地址空间和这些线程所需要的系统资源.一般来说,Linux系统会在进程之间共享程序代码和系统函数库,所以在任何时刻内存中都只有代码的一份拷贝. 1,ps命令 作用:p ...
 - HDU 2544 最短路(floyd+bellman-ford+spfa+dijkstra队列优化)
			
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544 题目大意:找点1到点n的最短路(无向图) 练一下最短路... dijkstra+队列优化: #i ...
 - java IntelliJ IDEA 13 注册码 IDEA序列号 License Key
			
java IntelliJ IDEA 13 注册码 IDEA序列号 License Key Username: JavaDeveloper@sskaje.me License: 282971-M1NW ...
 - sharepoint2013搜索
			
参考http://www.cnblogs.com/jianyus/p/3272692.html 最小权限http://www.cnblogs.com/awpatp/archive/2011/08/16 ...
 - 百度地图sdk定位和遇到的坑
			
封装定位服务类: import android.content.Context; import com.baidu.location.BDAbstractLocationListener; impor ...
 - 开源IDS系列--解决barnyard2 停止运行 libmysqlclient.so.16.0.0
			
现象: barnyard2运行一段时间后,会自行停止,未在/var/log/barnyard2或/var/log/suricata中发现相关日志. 排查: 在/var/log/message中存在以下 ...