这个看的确实有点问题,当时看到这道题的时候,当时我就一脸懵比,这是啥呀,一点也看不懂(原谅我英语太渣)这些单词都是串的,真是愚人呀/笑cry,大体上意思就是,erhe etsixs an iednx i scuh taht D mod M[i] = R[i],这句话有点用,其他的都没有用,所以我们就是求一个D MOD M[i] = R[i],最后除以一个数,
这个数是啥我也不知道,我就是除以了 1e6+5, 很幸运我成功了,后来我试了试,其实没有具体的数,除以720720
也行,1e6也行...
解题思路:
其实在上边已经说的差不多了,只要看懂了题意题目还是挺简单的...
My Code:
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long LL;
const int MAXN = 1e6+10;
int r[20],m[20];
int main()
{
int n;
while(cin>>n)
{
for(int i=0; i<n; i++)
cin>>m[i];
for(int i=0; i<n; i++)
cin>>r[i];
int sum = 0;
for(int i=0; i<MAXN; i++)
{
for(int j=0; j<n; j++)
{
if(i%m[j] == r[j])
{
sum++;
break;
}
}
}
printf("%.8lf\n",1.0*sum/(1.0*MAXN));
}
return 0;
}