fork download
  1. from math import gcd, ceil
  2.  
  3. t = int(input())
  4. while t>0:
  5. t-=1
  6. n = int(input())
  7. rebel = [int(i) for i in input().split(" ")]
  8. l, u = [int(i) for i in input().split(" ")] #army l u both inclusive
  9.  
  10. lcm = rebel[0]
  11. for i in rebel[1:]:
  12. lcm = lcm*i//gcd(lcm, i)
  13.  
  14. m = ceil(l/lcm)
  15. n = u//lcm
  16. ans = u-l+1-(n-m+1)
  17. # print(lcm, n, m, ans)
  18. print (ans if ans>0 else 0)
  19.  
  20.  
Success #stdin #stdout 0.02s 27664KB
stdin
1
500
1000000000 999999999 999999998 999999997 999999996 999999995 999999994 999999993 999999992 999999991 999999990 999999989 999999988 999999987 999999986 999999985 999999984 999999983 999999982 999999981 999999980 999999979 999999978 999999977 999999976 999999975 999999974 999999973 999999972 999999971 999999970 999999969 999999968 999999967 999999966 999999965 999999964 999999963 999999962 999999961 999999960 999999959 999999958 999999957 999999956 999999955 999999954 999999953 999999952 999999951 999999950 999999949 999999948 999999947 999999946 999999945 999999944 999999943 999999942 999999941 999999940 999999939 999999938 999999937 999999936 999999935 999999934 999999933 999999932 999999931 999999930 999999929 999999928 999999927 999999926 999999925 999999924 999999923 999999922 999999921 999999920 999999919 999999918 999999917 999999916 999999915 999999914 999999913 999999912 999999911 999999910 999999909 999999908 999999907 999999906 999999905 999999904 999999903 999999902 999999901 999999900 999999899 999999898 999999897 999999896 999999895 999999894 999999893 999999892 999999891 999999890 999999889 999999888 999999887 999999886 999999885 999999884 999999883 999999882 999999881 999999880 999999879 999999878 999999877 999999876 999999875 999999874 999999873 999999872 999999871 999999870 999999869 999999868 999999867 999999866 999999865 999999864 999999863 999999862 999999861 999999860 999999859 999999858 999999857 999999856 999999855 999999854 999999853 999999852 999999851 999999850 999999849 999999848 999999847 999999846 999999845 999999844 999999843 999999842 999999841 999999840 999999839 999999838 999999837 999999836 999999835 999999834 999999833 999999832 999999831 999999830 999999829 999999828 999999827 999999826 999999825 999999824 999999823 999999822 999999821 999999820 999999819 999999818 999999817 999999816 999999815 999999814 999999813 999999812 999999811 999999810 999999809 999999808 999999807 999999806 999999805 999999804 999999803 999999802 999999801 999999800 999999799 999999798 999999797 999999796 999999795 999999794 999999793 999999792 999999791 999999790 999999789 999999788 999999787 999999786 999999785 999999784 999999783 999999782 999999781 999999780 999999779 999999778 999999777 999999776 999999775 999999774 999999773 999999772 999999771 999999770 999999769 999999768 999999767 999999766 999999765 999999764 999999763 999999762 999999761 999999760 999999759 999999758 999999757 999999756 999999755 999999754 999999753 999999752 999999751 999999750 999999749 999999748 999999747 999999746 999999745 999999744 999999743 999999742 999999741 999999740 999999739 999999738 999999737 999999736 999999735 999999734 999999733 999999732 999999731 999999730 999999729 999999728 999999727 999999726 999999725 999999724 999999723 999999722 999999721 999999720 999999719 999999718 999999717 999999716 999999715 999999714 999999713 999999712 999999711 999999710 999999709 999999708 999999707 999999706 999999705 999999704 999999703 999999702 999999701 999999700 999999699 999999698 999999697 999999696 999999695 999999694 999999693 999999692 999999691 999999690 999999689 999999688 999999687 999999686 999999685 999999684 999999683 999999682 999999681 999999680 999999679 999999678 999999677 999999676 999999675 999999674 999999673 999999672 999999671 999999670 999999669 999999668 999999667 999999666 999999665 999999664 999999663 999999662 999999661 999999660 999999659 999999658 999999657 999999656 999999655 999999654 999999653 999999652 999999651 999999650 999999649 999999648 999999647 999999646 999999645 999999644 999999643 999999642 999999641 999999640 999999639 999999638 999999637 999999636 999999635 999999634 999999633 999999632 999999631 999999630 999999629 999999628 999999627 999999626 999999625 999999624 999999623 999999622 999999621 999999620 999999619 999999618 999999617 999999616 999999615 999999614 999999613 999999612 999999611 999999610 999999609 999999608 999999607 999999606 999999605 999999604 999999603 999999602 999999601 999999600 999999599 999999598 999999597 999999596 999999595 999999594 999999593 999999592 999999591 999999590 999999589 999999588 999999587 999999586 999999585 999999584 999999583 999999582 999999581 999999580 999999579 999999578 999999577 999999576 999999575 999999574 999999573 999999572 999999571 999999570 999999569 999999568 999999567 999999566 999999565 999999564 999999563 999999562 999999561 999999560 999999559 999999558 999999557 999999556 999999555 999999554 999999553 999999552 999999551 999999550 999999549 999999548 999999547 999999546 999999545 999999544 999999543 999999542 999999541 999999540 999999539 999999538 999999537 999999536 999999535 999999534 999999533 999999532 999999531 999999530 999999529 999999528 999999527 999999526 999999525 999999524 999999523 999999522 999999521 999999520 999999519 999999518 999999517 999999516 999999515 999999514 999999513 999999512 999999511 999999510 999999509 999999508 999999507 999999506 999999505 999999504 999999503 999999502 999999501
1 1000000000000000000
stdout
999999999999999999