#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int* m = new int[n];     int* r = new int[n];     for (int i = 0; i < n; i++) {       cin >> m[i];     }     for (int i = 0; i < n; i++) {       cin >> r[i];     }     double total = 0;     for (int i = 0; i < 1000000; i++) {       for (int j = 0; j < n; j++) {         if (i % m[j] == r[j]) {           total++;           break;         }       }     }     double percentage = total / 1000000;     cout << fixed << setprecision(6) << percentage << endl;   }   